Change:
this._terminalAltBufferActiveContextKey.set(!!(this.xterm && this.xterm.raw.buffer.active === this.xterm.raw.buffer.alternate)); } <ins> private async _shouldPasteText(text: string): Promise<boolean> { const textForLines = text.split(/r?n/); let confirmation: IConfirmationResult; // If the clipboard has only one line, no prompt will be triggered if (textForLines.length === 1 || !this._configurationService.getValue<boolean>(TerminalSettingId.EnableMultiLinePasteWarning)) { return true; } const displayItemsCount = 3; const maxPreviewLineLength = 30; let detail = 'Preview:'; for (let i = 0; i < Math.min(textForLines.length, displayItemsCount); i++) { const line = textForLines[i]; const cleanedLine = line.length > maxPreviewLineLength ? `${line.slice(0, maxPreviewLineLength)}…` : line; detail += `n${cleanedLine}`; } if (textForLines.length > displayItemsCount) { detail += `n…`; } confirmation = await this._dialogService.confirm({ type: 'question', message: nls.localize('confirmMoveTrashMessageFilesAndDirectories', "Are you sure you want to paste {0} lines of text into the terminal?", textForLines.length), detail, primaryButton: nls.localize({ key: 'multiLinePasteButton', comment: ['&& denotes a mnemonic'] }, "&&Paste"), checkbox: { label: nls.localize('doNotAskAgain', "Do not ask me again") } }); if (confirmation.confirmed && confirmation.checkboxChecked) { await this._configurationService.updateValue(TerminalSettingId.EnableMultiLinePasteWarning, false); } return confirmation.confirmed; } </ins> override dispose(immediate?: boolean): void { this._logService.trace(`terminalInstance#dispose (instanceId: ${this.instanceId})`); dispose(this._linkManager);

Discussion:
<!-- Do Not Delete This! featurerequesttemplate --<!-- Please read our Rules of Conduct: --<!-- Please search existing issues to avoid creating duplicates. --<!-- Describe the feature you'd like. --Please implement a for the VSCode integrated terminal, similar to Windows Terminal. ! 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.)
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
hi, can I work on this issue?
Hey - I haven't done any work on this yet. If you're interested, please do!
okayI will try to solve this problem :)
! 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
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.
Currently I am handling this situation by making a judgment before we execute 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)
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
Perhaps we could have three options, prompt for a brief message, prompt for the first two lines, and not prompt at all
Not sure what the right text should be, here's another example from iTerm: <img width="300" alt="CleanShot 2022-01-27 at 08 56 21 src="https://user-"I do like how simple the "confirm on delete" dialog looks with the preview: <img width="316" alt="CleanShot 2022-01-27 at 09 12 03 src="https://user-"<hrHow about something like:
Looks great , 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.
! 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: ! (I guess there won't be many people writing articles in vscode and using the terminal at the same time XD
In my test it doesn't care about the current 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.
created