From 2deb871ab227b2c994870755efc4b70753ea1841 Mon Sep 17 00:00:00 2001 From: George Fleming Date: Wed, 16 Mar 2016 09:29:00 -0700 Subject: [PATCH] Tested, except for reversed TreatControlCAsInput --- .../readline.cs | 20 +++++++++---------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/src/Microsoft.PowerShell.Linux.Host/readline.cs b/src/Microsoft.PowerShell.Linux.Host/readline.cs index 7c7d8c7b14..768f15f710 100644 --- a/src/Microsoft.PowerShell.Linux.Host/readline.cs +++ b/src/Microsoft.PowerShell.Linux.Host/readline.cs @@ -128,10 +128,10 @@ namespace Microsoft.PowerShell.Linux.Host { this.powershell.Runspace = runspace; this.Initialize(); - bool finishedTyping = false; + bool commandComplete = false; abort = false; // Console.WriteLine("Default value of TreatCtrlCAsInput: {0}", Console.TreatControlCAsInput); -// Console.TreatControlCAsInput = false; + Console.TreatControlCAsInput = false; while (true) { @@ -140,29 +140,28 @@ namespace Microsoft.PowerShell.Linux.Host // Basic Emacs-style readline implementation if (key.Modifiers.HasFlag(ConsoleModifiers.Control)) { - finishedTyping = ProcessControlKey(key, nested, ref abort); + commandComplete = ProcessControlKey(key, nested, ref abort); if (abort) { - Console.WriteLine(); -// Console.TreatControlCAsInput = true; + Console.TreatControlCAsInput = true; return String.Empty; } } else if (key.Modifiers.HasFlag(ConsoleModifiers.Alt)) { - finishedTyping = ProcessAltKey(key); + commandComplete = ProcessAltKey(key); } // Unmodified keys else { - finishedTyping = ProcessNormalKey(key, nested); + commandComplete = ProcessNormalKey(key, nested); } previousKeyPress = key; - if (finishedTyping) + if (commandComplete) { -// Console.TreatControlCAsInput = true; + Console.TreatControlCAsInput = true; return this.OnEnter(); } } @@ -217,10 +216,9 @@ namespace Microsoft.PowerShell.Linux.Host return this.OnEnter(); */ case ConsoleKey.C: - Console.WriteLine("received Ctrl-C"); this.Abort(); abort = true; - break; + return true; } return false; }