Multi-line paste fails to render properly in Terminal Preview, when copied from gist.github.com #10172

Closed
opened 2026-01-31 02:14:17 +00:00 by claunia · 7 comments
Owner

Originally created by @pcgeek86 on GitHub (Aug 14, 2020).

Environment

[cbt] C:\Users\TrevorSullivan\git> $PSVersionTable

Name                           Value
----                           -----
PSVersion                      7.0.3
PSEdition                      Core
GitCommitId                    7.0.3
OS                             Microsoft Windows 10.0.19041
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Windows Terminal 1.2.2234.0

Steps to reproduce

  1. Using Google Chrome, go to https://gist.github.com
  2. Create a new gist (but don't save it), using the example below
  3. Copy the text from the gist and paste it into the Microsoft Windows Terminal Preview
$Person = @{
  FirstName = 'Trevor'
  LastName = 'Sullivan'
  Likes = @(
    'Bacon',
    'Beer',
    'Software'
  )
}

This example fails as well:

@(
1
2
3
)

I can't be 100% sure, but it seems like maybe some "hidden" formatting from gist.github.com is causing this behavior? When I copied and pasted the examples using the GitHub issue editor (as I am authoring this), I can't reproduce it from here. 🤷🏻‍♂️

Expected behavior

The copied (unformatted) text is pasted precisely, character-for-character. The cursor position is at the end of the paste, so I can simply press ENTER to run the pasted command.

Actual behavior

The text is being pasted incorrectly. It appears that the first and last line of the paste are actually being reversed.

image

Also if I hit ENTER to run the command, it gets mangled even further. I'm not sure if the cursor position is actually where it visually appears to be.

image

Originally created by @pcgeek86 on GitHub (Aug 14, 2020). <!-- 🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨 I ACKNOWLEDGE THE FOLLOWING BEFORE PROCEEDING: 1. If I delete this entire template and go my own path, the core team may close my issue without further explanation or engagement. 2. If I list multiple bugs/concerns in this one issue, the core team may close my issue without further explanation or engagement. 3. If I write an issue that has many duplicates, the core team may close my issue without further explanation or engagement (and without necessarily spending time to find the exact duplicate ID number). 4. If I leave the title incomplete when filing the issue, the core team may close my issue without further explanation or engagement. 5. If I file something completely blank in the body, the core team may close my issue without further explanation or engagement. All good? Then proceed! --> <!-- This bug tracker is monitored by Windows Terminal development team and other technical folks. **Important: When reporting BSODs or security issues, DO NOT attach memory dumps, logs, or traces to Github issues**. Instead, send dumps/traces to secure@microsoft.com, referencing this GitHub issue. If this is an application crash, please also provide a Feedback Hub submission link so we can find your diagnostic data on the backend. Use the category "Apps > Windows Terminal (Preview)" and choose "Share My Feedback" after submission to get the link. Please use this form and describe your issue, concisely but precisely, with as much detail as possible. --> # Environment ```none [cbt] C:\Users\TrevorSullivan\git> $PSVersionTable Name Value ---- ----- PSVersion 7.0.3 PSEdition Core GitCommitId 7.0.3 OS Microsoft Windows 10.0.19041 Platform Win32NT PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…} PSRemotingProtocolVersion 2.3 SerializationVersion 1.1.0.1 WSManStackVersion 3.0 ``` **Windows Terminal 1.2.2234.0** # Steps to reproduce 1. Using Google Chrome, go to https://gist.github.com 2. Create a new gist (_but don't save it_), **using the example below** 3. Copy the text from the gist and paste it into the Microsoft Windows Terminal Preview ```powershell $Person = @{ FirstName = 'Trevor' LastName = 'Sullivan' Likes = @( 'Bacon', 'Beer', 'Software' ) } ``` This example fails as well: ``` @( 1 2 3 ) ``` I can't be 100% sure, but it seems like maybe some "hidden" formatting from gist.github.com is causing this behavior? When I copied and pasted the examples using the GitHub issue editor (as I am authoring this), I can't reproduce it from here. 🤷🏻‍♂️ # Expected behavior The copied (unformatted) text is pasted precisely, character-for-character. The cursor position is at the end of the paste, so I can simply press `ENTER` to run the pasted command. # Actual behavior The text is being pasted incorrectly. It appears that the first and last line of the paste are actually being reversed. ![image](https://user-images.githubusercontent.com/466713/90284835-e4b33380-de2f-11ea-94a9-f353a2e3a8b2.png) **Also** if I hit `ENTER` to run the command, it gets mangled even further. I'm not sure if the cursor position is actually where it visually appears to be. ![image](https://user-images.githubusercontent.com/466713/90284917-0ad8d380-de30-11ea-88b3-44f03a8ba1f3.png)
claunia added the Resolution-Duplicate label 2026-01-31 02:14:17 +00:00
Author
Owner

@DHowett commented on GitHub (Aug 15, 2020):

Thanks for the report! I think this is another instance of the problem in #5821, but I can't be sure. We end up sending the CR before the LF, and powershell reacts by moving to the beginning of the line:

1
2
3

becomes

|1

where the cursor is |

and then it inserts LF. PowerShell doesn't submit the command because pressing enter anywhere but the end of the line actually allows a line break. Then it sends 2

2|
1

CR

|2
1

and so on.

Working on our pasting story is gonna help this out, so I'm going to roll this together with /dup #5821.

@DHowett commented on GitHub (Aug 15, 2020): Thanks for the report! I think this is another instance of the problem in #5821, but I can't be sure. We end up sending the CR before the LF, and powershell reacts by moving to the beginning of the line: ``` 1 2 3 ``` becomes ``` |1 ``` where the cursor is `|` and then it inserts LF. PowerShell doesn't submit the command because pressing enter _anywhere but the end of the line_ actually allows a line break. Then it sends `2` ``` 2| 1 ``` CR ``` |2 1 ``` and so on. Working on our pasting story is gonna help this out, so I'm going to roll this together with /dup #5821.
Author
Owner

@ghost commented on GitHub (Aug 15, 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 (Aug 15, 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!
Author
Owner

@DHowett commented on GitHub (Aug 15, 2020):

(Also, that's a lovely color scheme. What is it?)

@DHowett commented on GitHub (Aug 15, 2020): (Also, that's a lovely color scheme. What is it?)
Author
Owner

@DHowett commented on GitHub (Aug 15, 2020):

Alright, confirmed:

image

those are LFs!

@DHowett commented on GitHub (Aug 15, 2020): Alright, confirmed: ![image](https://user-images.githubusercontent.com/189190/90302314-26f16a80-de5a-11ea-9b70-3d13bcb44579.png) those are LFs!
Author
Owner

@pcgeek86 commented on GitHub (Aug 15, 2020):

@DHowett it's just the built-in One Half Dark color scheme. 😀 I created a PowerShell module that makes it easy to switch between color schemes, and in the future other settings.

https://github.com/pcgeek86/terminal

@pcgeek86 commented on GitHub (Aug 15, 2020): @DHowett it's just the built-in `One Half Dark` color scheme. 😀 I created a PowerShell module that makes it easy to switch between color schemes, and in the future other settings. https://github.com/pcgeek86/terminal
Author
Owner

@pcgeek86 commented on GitHub (Aug 15, 2020):

Here's the video that shows the module in action (off-topic from OP)

https://youtu.be/0aMXBMSBE4Y

@pcgeek86 commented on GitHub (Aug 15, 2020): Here's the video that shows the module in action (off-topic from OP) https://youtu.be/0aMXBMSBE4Y
Author
Owner

@DHowett commented on GitHub (Aug 15, 2020):

Lovely! Thanks :D

@DHowett commented on GitHub (Aug 15, 2020): Lovely! Thanks :D
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#10172