From d6250e8086f57a37c4208265cf2b6954e58e17a4 Mon Sep 17 00:00:00 2001 From: Dongbo Wang Date: Tue, 19 Jun 2018 17:40:29 -0700 Subject: [PATCH] Revert the PR #7023 "Set the cursor to the place where a user hits tab key" (#7117) Reverts PowerShell/PowerShell#7023 due to a regression introduced by it. --- .../host/msh/ConsoleHostUserInterfaceProgress.cs | 6 ------ .../host/msh/ProgressPane.cs | 16 ++++------------ .../engine/MshCommandRuntime.cs | 2 +- 3 files changed, 5 insertions(+), 19 deletions(-) diff --git a/src/Microsoft.PowerShell.ConsoleHost/host/msh/ConsoleHostUserInterfaceProgress.cs b/src/Microsoft.PowerShell.ConsoleHost/host/msh/ConsoleHostUserInterfaceProgress.cs index 5e182b3e58..d8b19a6881 100644 --- a/src/Microsoft.PowerShell.ConsoleHost/host/msh/ConsoleHostUserInterfaceProgress.cs +++ b/src/Microsoft.PowerShell.ConsoleHost/host/msh/ConsoleHostUserInterfaceProgress.cs @@ -97,12 +97,6 @@ namespace Microsoft.PowerShell // Update the progress pane only when the timer set up the update flag or WriteProgress is completed. // As a result, we do not block WriteProgress and whole script and eliminate unnecessary console locks and updates. _progPane.Show(_pendingProgress); - - // Reset the cursor back to where it started - if (record.RecordType == ProgressRecordType.Completed) - { - _progPane.Hide(); - } } } diff --git a/src/Microsoft.PowerShell.ConsoleHost/host/msh/ProgressPane.cs b/src/Microsoft.PowerShell.ConsoleHost/host/msh/ProgressPane.cs index d8346b0cbd..922aad8f17 100644 --- a/src/Microsoft.PowerShell.ConsoleHost/host/msh/ProgressPane.cs +++ b/src/Microsoft.PowerShell.ConsoleHost/host/msh/ProgressPane.cs @@ -99,20 +99,12 @@ namespace Microsoft.PowerShell //if the cursor is at the bottom, create screen buffer space by scrolling int scrollRows = rows - ((_rawui.BufferSize.Height - 1) - _location.Y); + for (int i = 0; i < rows; i++) + { + Console.Out.Write('\n'); + } if (scrollRows > 0) { - // The following can be possibly replaced by Console.Write ("\x1b[" + scrollRows + "S"); - // For details, see https://docs.microsoft.com/en-us/windows/console/console-virtual-terminal-sequences - - // Scroll the console screen up by 'scrollRows' - var bottomLocation = _location; - bottomLocation.Y = _rawui.BufferSize.Height; - _rawui.CursorPosition = bottomLocation; - for (int i = 0; i < scrollRows; i++) - { - Console.Out.Write('\n'); - } - _location.Y -= scrollRows; _savedCursor.Y -= scrollRows; } diff --git a/src/System.Management.Automation/engine/MshCommandRuntime.cs b/src/System.Management.Automation/engine/MshCommandRuntime.cs index 8722b6d604..5b5b55809c 100644 --- a/src/System.Management.Automation/engine/MshCommandRuntime.cs +++ b/src/System.Management.Automation/engine/MshCommandRuntime.cs @@ -2254,7 +2254,7 @@ namespace System.Management.Automation { // Only generate these exceptions if a pipeline has already been declared as the 'writing' pipeline. // Otherwise, these are probably infrastructure messages and can be ignored. - if (this.PipelineProcessor?._permittedToWrite != null) + if (this.PipelineProcessor._permittedToWrite != null) { throw PSTraceSource.NewInvalidOperationException( PipelineStrings.WriteNotPermitted);