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

Open
opened 2026-01-31 00:06:33 +00:00 by claunia · 0 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:33 +00:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#5164