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 1
1
// Copyright (c) Microsoft Corporation.
2
2
// Licensed under the MIT License.
3
3
4
- using System . Collections . Generic ;
5
- using System . Management . Automation ;
6
- using System . Security ;
7
- using System . Text ;
8
- using System . Threading ;
9
4
using Microsoft . PowerShell . EditorServices . Services . PowerShell . Debugging ;
10
5
using Microsoft . PowerShell . EditorServices . Services . PowerShell . Execution ;
11
6
using Microsoft . PowerShell . EditorServices . Services . PowerShell . Host ;
7
+ using Microsoft . PowerShell . EditorServices . Services . PowerShell . Utility ;
8
+ using System . Collections . Generic ;
12
9
using System . Linq ;
10
+ using System . Management . Automation ;
13
11
using System . Management . Automation . Language ;
12
+ using System . Text ;
13
+ using System . Threading ;
14
14
15
15
namespace Microsoft . PowerShell . EditorServices . Services . PowerShell . Console
16
16
{
@@ -345,7 +345,7 @@ public override string ReadLine(CancellationToken cancellationToken)
345
345
return completedInput ;
346
346
347
347
default :
348
- if ( IsCtrlC ( keyInfo ) )
348
+ if ( keyInfo . IsCtrlC ( ) )
349
349
{
350
350
throw new PipelineStoppedException ( ) ;
351
351
}
Original file line number Diff line number Diff line change 1
1
// Copyright (c) Microsoft Corporation.
2
2
// Licensed under the MIT License.
3
3
4
+ using Microsoft . PowerShell . EditorServices . Services . PowerShell . Utility ;
5
+ using System . Management . Automation ;
4
6
using System . Security ;
5
7
using System . Threading ;
6
8
7
9
namespace Microsoft . PowerShell . EditorServices . Services . PowerShell . Console
8
10
{
9
11
using System ;
10
- using System . Management . Automation ;
11
12
12
13
internal abstract class TerminalReadLine : IReadLine
13
14
{
@@ -31,7 +32,7 @@ public SecureString ReadSecureLine(CancellationToken cancellationToken)
31
32
{
32
33
ConsoleKeyInfo keyInfo = ReadKey ( cancellationToken ) ;
33
34
34
- if ( IsCtrlC ( keyInfo ) )
35
+ if ( keyInfo . IsCtrlC ( ) )
35
36
{
36
37
throw new PipelineStoppedException ( ) ;
37
38
}
@@ -97,18 +98,5 @@ public SecureString ReadSecureLine(CancellationToken cancellationToken)
97
98
98
99
return secureString ;
99
100
}
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
-
113
101
}
114
102
}
Original file line number Diff line number Diff line change @@ -747,9 +747,7 @@ private ConsoleKeyInfo ReadKey(bool intercept)
747
747
private bool LastKeyWasCtrlC ( )
748
748
{
749
749
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 ( ) ;
753
751
}
754
752
755
753
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