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

Created on 14 Aug 2020  ยท  7Comments  ยท  Source: microsoft/terminal

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

Resolution-Duplicate

All 7 comments

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:

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.

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!

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

Alright, confirmed:

image

those are LFs!

@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

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

https://youtu.be/0aMXBMSBE4Y

Lovely! Thanks :D

Was this page helpful?
0 / 5 - 0 ratings

Related issues

mdtauk picture mdtauk  ยท  3Comments

mrmlnc picture mrmlnc  ยท  3Comments

mrmlnc picture mrmlnc  ยท  3Comments

miniksa picture miniksa  ยท  3Comments

warpdesign picture warpdesign  ยท  3Comments