From 68875f0942ab0d5f802b9b55aacabb52526f9104 Mon Sep 17 00:00:00 2001 From: Andrew Schwartzmeyer Date: Tue, 5 Jul 2016 19:30:29 -0700 Subject: [PATCH] Handle Ctrl-C while prompting --- .../host/msh/ConsoleHostUserInterface.cs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/Microsoft.PowerShell.ConsoleHost/host/msh/ConsoleHostUserInterface.cs b/src/Microsoft.PowerShell.ConsoleHost/host/msh/ConsoleHostUserInterface.cs index b1a4ae3bf..c2dedc666 100644 --- a/src/Microsoft.PowerShell.ConsoleHost/host/msh/ConsoleHostUserInterface.cs +++ b/src/Microsoft.PowerShell.ConsoleHost/host/msh/ConsoleHostUserInterface.cs @@ -1720,11 +1720,17 @@ namespace Microsoft.PowerShell // the empty string. #if LINUX + bool treatControlCAsInput = Console.TreatControlCAsInput; + + try + { + ConsoleKeyInfo keyInfo; string s = ""; int index = 0; int cursorLeft = Console.CursorLeft; int cursorCurrent = cursorLeft; + Console.TreatControlCAsInput = true; #else rawui.ClearKeyCache(); uint keyState = 0; @@ -1900,6 +1906,13 @@ namespace Microsoft.PowerShell "s should only be null if input ended with a break"); return s; +#if LINUX + } + finally + { + Console.TreatControlCAsInput = treatControlCAsInput; + } +#endif } ///