Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement multiLinePasteWarning in VSCode terminal, similar to Windows Terminal behavior #122683

Closed
cruscio opened this issue Apr 29, 2021 · 18 comments · Fixed by #141822
Closed
Assignees
Labels
feature-request Request for new features or functionality help wanted Issues identified as good community contribution opportunities insiders-released Patch has been released in VS Code Insiders on-testplan terminal Integrated terminal issues
Milestone

Comments

@cruscio
Copy link

cruscio commented Apr 29, 2021

Please implement a multiLinePasteWarning for the VSCode integrated terminal, similar to Windows Terminal.

image

More times than I care to admit, I've accidentally pasted bad text into a VSCode integrated terminal session - often due to either the wrong panel being in focus, or fat fingering an unintended right-mouse-click at a bad place/time.

VSCode workspaces have replaced 99% of my standalone terminal usage these days. Having that safety net is by far the top of my missing-features wish list.

(... and I was surprised to come up empty handed when searching for an existing setting or open issue.)

@meganrogge meganrogge added feature-request Request for new features or functionality terminal Integrated terminal issues labels Apr 29, 2021
@Tyriar Tyriar modified the milestones: Backlog Candidates, Backlog Jun 30, 2021
@Tyriar Tyriar added the help wanted Issues identified as good community contribution opportunities label Jun 30, 2021
@Tyriar Tyriar reopened this Jun 30, 2021
@Tyriar
Copy link
Member

Tyriar commented Jun 30, 2021

I think it would be good to have an opt-in setting for this as I've accidentally pasted the wrong thing as well which could be destructive. Opening up to PRs

@weartist
Copy link
Contributor

weartist commented Jan 24, 2022

hi, can I work on this issue?

I think it would be good to have an opt-in setting for this as I've accidentally pasted the wrong thing as well which could be destructive. Opening up to PRs

@cruscio
Copy link
Author

cruscio commented Jan 24, 2022

Hey @slidoooor - I haven't done any work on this yet. If you're interested, please do!

@weartist
Copy link
Contributor

Hey @slidoooor - I haven't done any work on this yet. If you're interested, please do!

okay,I will try to solve this problem :)

@weartist
Copy link
Contributor

image

@cruscio @Tyriar How do you all feel? I think the text is a bit crowded and if we want to display the clipboard it will be even more crowded

@Tyriar
Copy link
Member

Tyriar commented Jan 27, 2022

@misolori any opinions here for how to present this warning when pasting multiple lines into the terminal? It'll probably be opt-in and ideally I think it would have a preview of the first 2 lines.

@weartist
Copy link
Contributor

Currently I am handling this situation by making a judgment before we execute paste:

await accessor.get(ITerminalService).activeInstance?.paste();

But it's not easy to get to the clipboard here

We can also handle it here and can easily get the clipboard:


But this means that all pastes in the terminal will be detected (e.g right click behavior paste)

@Tyriar
Copy link
Member

Tyriar commented Jan 27, 2022

But this means that all pastes in the terminal will be detected (e.g right click behavior paste)

Not sure what the right behavior is here, does Windows Terminal show it on right click as well?

@weartist
Copy link
Contributor

But this means that all pastes in the terminal will be detected (e.g right click behavior paste)

Not sure what the right behavior is here, does Windows Terminal show it on right click as well?

I tried it and it does prompt

@weartist
Copy link
Contributor

Perhaps we could have three options, prompt for a brief message, prompt for the first two lines, and not prompt at all

@miguelsolorio
Copy link
Contributor

Not sure what the right text should be, here's another example from iTerm:

CleanShot 2022-01-27 at 08 56 21@2x

I do like how simple the "confirm on delete" dialog looks with the preview:

CleanShot 2022-01-27 at 09 12 03@2x


How about something like:

Are you sure you want to paste the following xx lines to the terminal?
line one
line two...
This may result in the unexpected execution of commands
[Paste] [Cancel]

@Tyriar
Copy link
Member

Tyriar commented Jan 27, 2022

Are you sure you want to paste the following xx lines to the terminal?
line one
line two...
This may result in the unexpected execution of commands
[Paste] [Cancel]

Looks great 👍, @slidoooor let's go with that. We could enable it by default with the don't ask me again checkbox to change the setting for you.

@weartist
Copy link
Contributor

weartist commented Jan 30, 2022

image

@Tyriar @misolori Hi!, I committed the latest changes and it currently looks like this.
I've only done it in the 'paste', not deal wit 'pasteSelection', which I assume has the expected behavior in general? Do we need to process both?

Another small problem is that I am handling the lines by separator, and if the user's pasteboard has only two lines, but each line is very long, there will also be a lot of content displayed, e.g:

image

(I guess there won't be many people writing articles in vscode and using the terminal at the same time XD

@Tyriar Tyriar modified the milestones: Backlog, February 2022 Jan 31, 2022
Tyriar added a commit that referenced this issue Feb 1, 2022
Implement multiLinePasteWarning in VSCode terminal,fix the #122683
@yume-chan
Copy link
Contributor

yume-chan commented Feb 8, 2022

In my test it doesn't care about the current Paste Bracketing state. It should be fine (no warning) if current program can handle multi-line paste.

EDIT: Tested in Windows Terminal, no warning if Paste Bracketing is on.

@Tyriar
Copy link
Member

Tyriar commented Feb 8, 2022

@yume-chan 👍 created #142525

@github-actions github-actions bot locked and limited conversation to collaborators Mar 18, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
feature-request Request for new features or functionality help wanted Issues identified as good community contribution opportunities insiders-released Patch has been released in VS Code Insiders on-testplan terminal Integrated terminal issues
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants
@yume-chan @Tyriar @weartist @meganrogge @cruscio @miguelsolorio and others