Pasting multiple lines of code must not execute them immediately #11202

Closed
opened 2026-01-31 02:41:21 +00:00 by claunia · 2 comments
Owner

Originally created by @danielniccoli on GitHub (Oct 29, 2020).

Environment

Windows build number: 10.0.19042.0
Windows Terminal version: 1.3.2651.0

Steps to reproduce

Copy this code and paste it into PowerShell 5.1 and Windows Terminal by either right-clicking in the window, or by pressing CTRL-V.

"This is a very"
"very"
$x = 1+1
"very"
"very long script that I like to paste without invoking it in-between"

Expected behavior

The code should be pasted as one block of code, waiting to be invoked by manually pressing enter.
When pressing ARROWUP the complete block should be retrieved from the history.

image

Actual behavior

The code is pasted line-per-line. A NewLine character in the code does invoke everything that was pasted before. The only exception are if a NewLine character is found withing braces.
Pressing ARROWUP does only retrieve the last line of the block of code, because Terminal treated them as individual commands, due to the NewLine characters that are mistreated.

image

Originally created by @danielniccoli on GitHub (Oct 29, 2020). # Environment ```none Windows build number: 10.0.19042.0 Windows Terminal version: 1.3.2651.0 ``` # Steps to reproduce Copy this code and paste it into PowerShell 5.1 and Windows Terminal by either right-clicking in the window, or by pressing CTRL-V. ```powershell "This is a very" "very" $x = 1+1 "very" "very long script that I like to paste without invoking it in-between" ``` # Expected behavior The code should be pasted as one block of code, waiting to be invoked by manually pressing enter. When pressing ARROWUP the complete block should be retrieved from the history. ![image](https://user-images.githubusercontent.com/2971735/97539902-12396300-19c3-11eb-8015-c4a4afbba3b3.png) # Actual behavior The code is pasted line-per-line. A `NewLine` character in the code does invoke everything that was pasted before. The only exception are if a `NewLine` character is found withing braces. Pressing ARROWUP does only retrieve the last line of the block of code, because Terminal treated them as individual commands, due to the `NewLine` characters that are mistreated. ![image](https://user-images.githubusercontent.com/2971735/97539923-19607100-19c3-11eb-9287-fad37cb824b4.png)
claunia added the Resolution-Duplicate label 2026-01-31 02:41:21 +00:00
Author
Owner

@DHowett commented on GitHub (Oct 29, 2020):

/dup #395 bracketed paste mode is the way shells can detect that a large amount of content was pasted from the clipboard

this will almost certainly never work in traditional Windows PowerShell.

Note: powershell has a ^V binding that causes it to read the clipboard. It may be more reliable than having Terminal send the clipboard (and prevent this problem), but it will not work remotely/over SSH

@DHowett commented on GitHub (Oct 29, 2020): /dup #395 bracketed paste mode is the way shells can detect that a large amount of content was pasted from the clipboard this will almost certainly _never work_ in traditional Windows PowerShell. Note: powershell has a ^V binding that causes it to read the clipboard. It may be more reliable than having Terminal send the clipboard (and prevent this problem), but it will not work remotely/over SSH
Author
Owner

@ghost commented on GitHub (Oct 29, 2020):

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 (Oct 29, 2020): 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!
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#11202