File tree Expand file tree Collapse file tree 4 files changed +33
-24
lines changed
src/PowerShellEditorServices/Services/PowerShell Expand file tree Collapse file tree 4 files changed +33
-24
lines changed Original file line number Diff line number Diff line change 11// Copyright (c) Microsoft Corporation.
22// Licensed under the MIT License.
33
4- using System . Collections . Generic ;
5- using System . Management . Automation ;
6- using System . Security ;
7- using System . Text ;
8- using System . Threading ;
94using Microsoft . PowerShell . EditorServices . Services . PowerShell . Debugging ;
105using Microsoft . PowerShell . EditorServices . Services . PowerShell . Execution ;
116using Microsoft . PowerShell . EditorServices . Services . PowerShell . Host ;
7+ using Microsoft . PowerShell . EditorServices . Services . PowerShell . Utility ;
8+ using System . Collections . Generic ;
129using System . Linq ;
10+ using System . Management . Automation ;
1311using System . Management . Automation . Language ;
12+ using System . Text ;
13+ using System . Threading ;
1414
1515namespace Microsoft . PowerShell . EditorServices . Services . PowerShell . Console
1616{
@@ -345,7 +345,7 @@ public override string ReadLine(CancellationToken cancellationToken)
345345 return completedInput ;
346346
347347 default :
348- if ( IsCtrlC ( keyInfo ) )
348+ if ( keyInfo . IsCtrlC ( ) )
349349 {
350350 throw new PipelineStoppedException ( ) ;
351351 }
Original file line number Diff line number Diff line change 11// Copyright (c) Microsoft Corporation.
22// Licensed under the MIT License.
33
4+ using Microsoft . PowerShell . EditorServices . Services . PowerShell . Utility ;
5+ using System . Management . Automation ;
46using System . Security ;
57using System . Threading ;
68
79namespace Microsoft . PowerShell . EditorServices . Services . PowerShell . Console
810{
911 using System ;
10- using System . Management . Automation ;
1112
1213 internal abstract class TerminalReadLine : IReadLine
1314 {
@@ -31,7 +32,7 @@ public SecureString ReadSecureLine(CancellationToken cancellationToken)
3132 {
3233 ConsoleKeyInfo keyInfo = ReadKey ( cancellationToken ) ;
3334
34- if ( IsCtrlC ( keyInfo ) )
35+ if ( keyInfo . IsCtrlC ( ) )
3536 {
3637 throw new PipelineStoppedException ( ) ;
3738 }
@@ -97,18 +98,5 @@ public SecureString ReadSecureLine(CancellationToken cancellationToken)
9798
9899 return secureString ;
99100 }
100-
101- protected static bool IsCtrlC ( ConsoleKeyInfo keyInfo )
102- {
103- if ( ( int ) keyInfo . Key == 3 )
104- {
105- return true ;
106- }
107-
108- return keyInfo . Key == ConsoleKey . C
109- && ( keyInfo . Modifiers & ConsoleModifiers . Control ) != 0
110- && ( keyInfo . Modifiers & ConsoleModifiers . Alt ) == 0 ;
111- }
112-
113101 }
114102}
Original file line number Diff line number Diff line change @@ -747,9 +747,7 @@ private ConsoleKeyInfo ReadKey(bool intercept)
747747 private bool LastKeyWasCtrlC ( )
748748 {
749749 return _lastKey . HasValue
750- && _lastKey . Value . Key == ConsoleKey . C
751- && ( _lastKey . Value . Modifiers & ConsoleModifiers . Control ) != 0
752- && ( _lastKey . Value . Modifiers & ConsoleModifiers . Alt ) == 0 ;
750+ && _lastKey . Value . IsCtrlC ( ) ;
753751 }
754752
755753 private void OnDebuggerStopped ( object sender , DebuggerStopEventArgs debuggerStopEventArgs )
Original file line number Diff line number Diff line change 1+ // Copyright (c) Microsoft Corporation.
2+ // Licensed under the MIT License.
3+
4+ using System ;
5+
6+ namespace Microsoft . PowerShell . EditorServices . Services . PowerShell . Utility
7+ {
8+ internal static class ConsoleKeyInfoExtensions
9+ {
10+ public static bool IsCtrlC ( this ConsoleKeyInfo keyInfo )
11+ {
12+ if ( ( int ) keyInfo . Key == 3 )
13+ {
14+ return true ;
15+ }
16+
17+ return keyInfo . Key == ConsoleKey . C
18+ && ( keyInfo . Modifiers & ConsoleModifiers . Control ) != 0
19+ && ( keyInfo . Modifiers & ConsoleModifiers . Shift ) == 0
20+ && ( keyInfo . Modifiers & ConsoleModifiers . Alt ) == 0 ;
21+ }
22+ }
23+ }
You can’t perform that action at this time.
0 commit comments