terminal icon indicating copy to clipboard operation
terminal copied to clipboard

Copy of a single wrapped line from bash introduces new-lines

Open vadimkantorov opened this issue 3 years ago • 8 comments

Windows Terminal version

1.14.2282.0

Windows build number

10.0.22000.978

Other Software

No response

Steps to reproduce

I have launched a long command in WSLv1 bash in Terminal, it looks like:

vadimkantorov@dell_de_vadim:/mnt/c/Users/vadim/$ python ..... my long arguments
long arguments wrapped by terminal window size but still a single line

When I copy these two lines (e.g. for pasting later in another terminal for launching a similar command in parallel), Terminal introduces a newline which was not there originally. This prevents from a proper paste and (probably another issue) - also executes the incomplete command immediately after the paste. It's possible that I entered this command by pressing Up on keyboard which brought this command from bash history.

This must have been reported before, but I could not find an earlier issue just about this. If it indeed is a duplicate, please feel free to close this.

Expected Behavior

No response

Actual Behavior

No newline is introduced and command is not executed immediately after the paste in another tab

vadimkantorov avatar Sep 19 '22 14:09 vadimkantorov

This is a bit nuanced.

bash (more accurately, probably readline) implements its own hard wrapping. As a result, we can't totally tell that a line was intended to be a continuation instead of a physical line break.

When I type this:

image

Bash sends this:

reach the edge ABCDEFGHIJKL:M \nNOP
                             ^^^

That space and newline were produced by them. I'm at a loss as to exactly why they do this. ☹️

DHowett avatar Sep 19 '22 17:09 DHowett

probably the command is actually executed because of this newline too

vadimkantorov avatar Sep 19 '22 17:09 vadimkantorov

maybe could be hacked around by a context menu command "Paste without newlines", but it's not very satisfactory

vadimkantorov avatar Sep 19 '22 17:09 vadimkantorov

Holding down Shift while you copy will force the entire selection to wrap onto a single line. It's not ideal because you won't necessarily know when to use it versus not use it, but it might be a good tactical solution for this specific issue. Sorry :/

DHowett avatar Sep 19 '22 17:09 DHowett

Until now, I've been relying on auto-copy on mouse selection. I wonder, if Terminal can at least provide some visual hints on copy or on paste if the text includes new-lines to educate about this option. Btw Ctrl+Shift+C is default on Gnome Terminal, will this shortcut in WT also just apply these newline removal? or only if Shift is used during mouse-selection?

vadimkantorov avatar Sep 19 '22 17:09 vadimkantorov

That space and newline were produced by them. I'm at a loss as to exactly why they do this. ☹️

Yea, I wonder if there's somewhere a mailing list or bash/readline authors that could address this...

Does Mac's Terminals handle this somehow?

vadimkantorov avatar Sep 19 '22 17:09 vadimkantorov

Also, I don't know why but for me this problem doesn't happen every time, only occasionally. So there may be some other aspects

vadimkantorov avatar Sep 19 '22 18:09 vadimkantorov

without properly triaging:

  • #6901
  • #6987
  • #8976
  • #9359
  • #9933
  • #11459

zadjii-msft avatar Sep 19 '22 19:09 zadjii-msft

I think I'm gonna call this a /dupe of #6901. We should probably go through and de-dupe the rest of those too.

zadjii-msft avatar Nov 08 '22 20:11 zadjii-msft

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 avatar Nov 08 '22 20:11 ghost