Blank lines and error messages occur when pasting with right click of mouse #5166

Closed
opened 2026-01-31 00:06:36 +00:00 by claunia · 3 comments
Owner

Originally created by @steveharsant on GitHub (Nov 25, 2019).

Environment

Platform ServicePack Version      VersionString
-------- ----------- -------      -------------
 Win32NT             10.0.18362.0 Microsoft Windows NT 10.0.18362.0

Windows Terminal (Preview)
Version: 0.6.2951.0

$PSVersionTable.PSVersion
Major  Minor  Build  Revision
-----  -----  -----  --------
5      1      18362  145

Steps to reproduce

  • Open Windows terminal with a Powershell tab
  • Copy a function containing an if statement
  • Paste the copied code with mouse right click (ctrl+v does not produce this behaviour)

Expected behavior

Copied function should be pasted with the same behaviour as ctrl+v.
i.e. Pasted code should not be interpreted until the enter key is pressed, with the same formatting as the source it was copied from.

Actual behavior

  • When pasting with right-click of the mouse, extra blank lines are generated between code and at the end of the copied text.
  • An error message is populate once per if statement. The error message reads:
Oops, something went wrong.  Please report this bug with the details below.
Report on GitHub: https://github.com/lzybkr/PSReadLine/issues/new
-----------------------------------------------------------------------
Last 200 Keys:
 p a c e s Enter
 Ctrl+Enter Space Space Space Space Space Space Space Space $ m e s s a g e Space = Space @ { Enter
 Ctrl+Enter Space Space Space Space Space Space Space Space Space Space Space Space t i t l e Space = Space $ t i t l e ; Enter
 Ctrl+Enter Space Space Space Space Space Space Space Space Space Space Space Space t e x t Space = Space $ b o d y T e x t . R e p l a c e ( " ` n " , Space " Space Space ` n " ) Enter
 Ctrl+Enter Space Space Space Space Space Space Space Space } Enter
 Ctrl+Enter Space Space Space Space Space Space Space Space i f ( T e s t - P a t h Space - p a t h Space C : \ ) Enter
 Ctrl+Enter Space Space Space Space Space Space Space Space { Enter
 Ctrl+Enter Space Space Space Space Space Space Space Space Space Space Space Space Enter
 Ctrl+Enter Space Space Space Space Space Space Space Space } Enter
 Ctrl+Enter Enter
 Ctrl+Enter Enter
 Ctrl+Enter Enter
 Ctrl+Enter Enter
 Ctrl+Enter }

Exception:
System.ArgumentOutOfRangeException: The value must be greater than or equal to zero and less than the console's buffer size in that dimension.
Parameter name: top
Actual value was -2.
   at System.Console.SetCursorPosition(Int32 left, Int32 top)
   at Microsoft.PowerShell.PSConsoleReadLine.ReallyRender(RenderData renderData, String defaultColor)
   at Microsoft.PowerShell.PSConsoleReadLine.ForceRender()
   at Microsoft.PowerShell.PSConsoleReadLine.Insert(Char c)
   at Microsoft.PowerShell.PSConsoleReadLine.AcceptLineImpl(Boolean validate)
   at Microsoft.PowerShell.PSConsoleReadLine.ProcessOneKey(ConsoleKeyInfo key, Dictionary`2 dispatchTable, Boolean ignoreIfNoAction, Object arg)
   at Microsoft.PowerShell.PSConsoleReadLine.InputLoop()
   at Microsoft.PowerShell.PSConsoleReadLine.ReadLine(Runspace runspace, EngineIntrinsics engineIntrinsics)
-----------------------------------------------------------------------

Aditional Information

  • Although when using ctrl+v to paste, the error messages do not occur, extra blank lines are still generated.
  • This behaviour (both the error messages and blank lines) do not occur with vanialla Powershell
Originally created by @steveharsant on GitHub (Nov 25, 2019). # Environment ``` Platform ServicePack Version VersionString -------- ----------- ------- ------------- Win32NT 10.0.18362.0 Microsoft Windows NT 10.0.18362.0 Windows Terminal (Preview) Version: 0.6.2951.0 $PSVersionTable.PSVersion Major Minor Build Revision ----- ----- ----- -------- 5 1 18362 145 ``` # Steps to reproduce * Open Windows terminal with a Powershell tab * Copy a function containing an `if` statement * Paste the copied code with mouse right click (`ctrl+v` does not produce this behaviour) # Expected behavior Copied function should be pasted with the same behaviour as `ctrl+v`. i.e. Pasted code should not be interpreted until the `enter` key is pressed, with the same formatting as the source it was copied from. # Actual behavior * When pasting with right-click of the mouse, extra blank lines are generated between code and at the end of the copied text. * An error message is populate once per `if` statement. The error message reads: ``` Oops, something went wrong. Please report this bug with the details below. Report on GitHub: https://github.com/lzybkr/PSReadLine/issues/new ----------------------------------------------------------------------- Last 200 Keys: p a c e s Enter Ctrl+Enter Space Space Space Space Space Space Space Space $ m e s s a g e Space = Space @ { Enter Ctrl+Enter Space Space Space Space Space Space Space Space Space Space Space Space t i t l e Space = Space $ t i t l e ; Enter Ctrl+Enter Space Space Space Space Space Space Space Space Space Space Space Space t e x t Space = Space $ b o d y T e x t . R e p l a c e ( " ` n " , Space " Space Space ` n " ) Enter Ctrl+Enter Space Space Space Space Space Space Space Space } Enter Ctrl+Enter Space Space Space Space Space Space Space Space i f ( T e s t - P a t h Space - p a t h Space C : \ ) Enter Ctrl+Enter Space Space Space Space Space Space Space Space { Enter Ctrl+Enter Space Space Space Space Space Space Space Space Space Space Space Space Enter Ctrl+Enter Space Space Space Space Space Space Space Space } Enter Ctrl+Enter Enter Ctrl+Enter Enter Ctrl+Enter Enter Ctrl+Enter Enter Ctrl+Enter } Exception: System.ArgumentOutOfRangeException: The value must be greater than or equal to zero and less than the console's buffer size in that dimension. Parameter name: top Actual value was -2. at System.Console.SetCursorPosition(Int32 left, Int32 top) at Microsoft.PowerShell.PSConsoleReadLine.ReallyRender(RenderData renderData, String defaultColor) at Microsoft.PowerShell.PSConsoleReadLine.ForceRender() at Microsoft.PowerShell.PSConsoleReadLine.Insert(Char c) at Microsoft.PowerShell.PSConsoleReadLine.AcceptLineImpl(Boolean validate) at Microsoft.PowerShell.PSConsoleReadLine.ProcessOneKey(ConsoleKeyInfo key, Dictionary`2 dispatchTable, Boolean ignoreIfNoAction, Object arg) at Microsoft.PowerShell.PSConsoleReadLine.InputLoop() at Microsoft.PowerShell.PSConsoleReadLine.ReadLine(Runspace runspace, EngineIntrinsics engineIntrinsics) ----------------------------------------------------------------------- ``` # Aditional Information * Although when using `ctrl+v` to paste, the error messages do not occur, extra blank lines are still generated. * This behaviour (both the error messages and blank lines) do not occur with vanialla Powershell
claunia added the Resolution-Duplicate label 2026-01-31 00:06:36 +00:00
Author
Owner

@DHowett-MSFT commented on GitHub (Nov 25, 2019):

This is a /dupe of #1091, which will be fixed in the next release.

@DHowett-MSFT commented on GitHub (Nov 25, 2019): This is a /dupe of #1091, which will be fixed in the next release.
Author
Owner

@ghost commented on GitHub (Nov 25, 2019):

Hi! We've identified this issue as a duplicate of another one that already exists on this Issue Tracker. This specific instance is being closed in favor of tracking the concern over on the referenced thread. Thanks for your report!

@ghost commented on GitHub (Nov 25, 2019): Hi! We've identified this issue as a duplicate of another one that already exists on this Issue Tracker. This specific instance is being closed in favor of tracking the concern over on the referenced thread. Thanks for your report!
Author
Owner

@steveharsant commented on GitHub (Nov 26, 2019):

This is a /dupe of #1091, which will be fixed in the next release.

@DHowett-MSFT thank you, and apologies for the dupe, I couldn't find it when searching for one

@steveharsant commented on GitHub (Nov 26, 2019): > This is a /dupe of #1091, which will be fixed in the next release. @DHowett-MSFT thank you, and apologies for the dupe, I couldn't find it when searching for one
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#5166