Skip to content

Commit 7b429a3

Browse files
committedApr 4, 2022
Remove UnixConsoleEcho now that PS6 is unsupported
1 parent c49fa2a commit 7b429a3

File tree

4 files changed

+3
-51
lines changed

4 files changed

+3
-51
lines changed
 

‎.vsts-ci/templates/release-general.yml

-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ steps:
4646
**/Newtonsoft.Json.dll
4747
**/OmniSharp*.dll
4848
**/Serilog*.dll
49-
**/UnixConsoleEcho.dll
5049
5150
# The SBOM generation requires our original sources with the `dotnet restore`
5251
# produced `project.assets.json` files.

‎Third Party Notices.txt

-15
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,6 @@ This file is based on or incorporates material from the projects listed below (T
44

55
---
66

7-
UnixConsoleEcho
8-
9-
Copyright (c) 2017 Patrick Meinecke
10-
Provided for Informational Purposes Only
11-
12-
MIT License
13-
14-
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the Software), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
15-
16-
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
17-
18-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
19-
20-
---
21-
227
Serilog
238

249
Copyright 2013-2015 Serilog Contributors

‎src/PowerShellEditorServices/PowerShellEditorServices.csproj

-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@
3838
<PackageReference Include="System.IO.Pipes.AccessControl" Version="5.0.0" />
3939
<PackageReference Include="System.Security.Principal" Version="4.3.0" />
4040
<PackageReference Include="System.Security.Principal.Windows" Version="5.0.0" />
41-
<PackageReference Include="UnixConsoleEcho" Version="0.1.0" />
4241
</ItemGroup>
4342

4443
<ItemGroup>

‎src/PowerShellEditorServices/Services/PowerShell/Console/UnixConsoleOperations.cs

+3-34
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
using System.Threading;
66
using System.Threading.Tasks;
77
using Microsoft.PowerShell.EditorServices.Utility;
8-
using UnixConsoleEcho;
98

109
namespace Microsoft.PowerShell.EditorServices.Services.PowerShell.Console
1110
{
@@ -43,35 +42,19 @@ public ConsoleKeyInfo ReadKey(bool intercept, CancellationToken cancellationToke
4342
// On Unix platforms System.Console.ReadKey has an internal lock on stdin. Because
4443
// of this, if a ReadKey call is pending in one thread and in another thread
4544
// Console.CursorLeft is called, both threads block until a key is pressed.
46-
47-
// To work around this we wait for a key to be pressed before actually calling Console.ReadKey.
48-
// However, any pressed keys during this time will be echoed to the console. To get around
49-
// this we use the UnixConsoleEcho package to disable echo prior to waiting.
50-
if (VersionUtils.IsPS6)
51-
{
52-
InputEcho.Disable();
53-
}
54-
5545
try
5646
{
5747
// The WaitForKeyAvailable delegate switches between a long delay between waits and
5848
// a short timeout depending on how recently a key has been pressed. This allows us
5949
// to let the CPU enter low power mode without compromising responsiveness.
60-
while (!WaitForKeyAvailable(cancellationToken))
61-
{
62-
;
63-
}
50+
while (!WaitForKeyAvailable(cancellationToken)) { }
6451
}
6552
finally
6653
{
67-
if (VersionUtils.IsPS6)
68-
{
69-
InputEcho.Disable();
70-
}
7154
s_readKeyHandle.Release();
7255
}
7356

74-
// A key has been pressed, so aquire a lock on our internal stdin handle. This is done
57+
// A key has been pressed, so acquire a lock on our internal stdin handle. This is done
7558
// so any of our calls to cursor position API's do not release ReadKey.
7659
s_stdInHandle.Wait(cancellationToken);
7760
try
@@ -88,26 +71,12 @@ public async Task<ConsoleKeyInfo> ReadKeyAsync(bool intercept, CancellationToken
8871
{
8972
await s_readKeyHandle.WaitAsync(cancellationToken).ConfigureAwait(false);
9073

91-
// I tried to replace this library with a call to `stty -echo`, but unfortunately
92-
// the library also sets up allowing backspace to trigger `Console.KeyAvailable`.
93-
if (VersionUtils.IsPS6)
94-
{
95-
InputEcho.Disable();
96-
}
97-
9874
try
9975
{
100-
while (!await WaitForKeyAvailableAsync(cancellationToken).ConfigureAwait(false))
101-
{
102-
;
103-
}
76+
while (!await WaitForKeyAvailableAsync(cancellationToken).ConfigureAwait(false)) { }
10477
}
10578
finally
10679
{
107-
if (VersionUtils.IsPS6)
108-
{
109-
InputEcho.Enable();
110-
}
11180
s_readKeyHandle.Release();
11281
}
11382

0 commit comments

Comments
 (0)