Use bracketed paste for multiline executed terminal text#302526
Merged
meganrogge merged 5 commits intomicrosoft:mainfrom Mar 19, 2026
Merged
Use bracketed paste for multiline executed terminal text#302526meganrogge merged 5 commits intomicrosoft:mainfrom
meganrogge merged 5 commits intomicrosoft:mainfrom
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates TerminalInstance.sendText to automatically wrap multiline text in bracketed paste sequences when the terminal has bracketed paste mode enabled, and adds a unit test to cover the multiline executed-text behavior.
Changes:
- Automatically enable bracketed paste wrapping when
sendTextreceives multiline text and xterm reports bracketed paste mode is enabled. - Preserve existing behavior for callers explicitly requesting bracketed paste mode.
- Add a unit test validating multiline executed text is sent wrapped in bracketed paste sequences.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| src/vs/workbench/contrib/terminal/browser/terminalInstance.ts | Adjusts sendText to auto-apply bracketed paste for multiline text when supported/enabled. |
| src/vs/workbench/contrib/terminal/test/browser/terminalInstance.test.ts | Adds a regression/unit test for multiline executed text using bracketed paste, and refactors instance creation into a helper. |
src/vs/workbench/contrib/terminal/test/browser/terminalInstance.test.ts
Outdated
Show resolved
Hide resolved
meganrogge
approved these changes
Mar 19, 2026
Collaborator
|
cc @Tyriar |
This was referenced Mar 19, 2026
lszomoru
approved these changes
Mar 19, 2026
TylerLeonhardt
approved these changes
Mar 19, 2026
kh4f
added a commit
to kh4f/vscode
that referenced
this pull request
Mar 21, 2026
…quences PR microsoft#302526 introduced automatic bracketed paste for any text containing `\r` or `\n`. This unintentionally changed the behavior of `sendText(text, false)` for control sequences such as `\u000D`, which could previously be sent as raw keystrokes via the `workbench.action.terminal.sendSequence` command to simulate Enter. This patch restores the original behavior by applying automatic bracketed paste only when: - explicitly requested via `bracketedPasteMode`, or - the text is multiline *and* `shouldExecute` is true This preserves the multiline execution fix while keeping non-executed control sequences raw. A regression test is included to verify that `sendText('\r', false)` sends a plain `\r` to the pty instead of wrapping it in bracketed paste. Fixes microsoft#303665
meganrogge
added a commit
that referenced
this pull request
Mar 23, 2026
meganrogge
added a commit
that referenced
this pull request
Mar 23, 2026
meganrogge
added a commit
that referenced
this pull request
Mar 23, 2026
kh4f
added a commit
to kh4f/vscode
that referenced
this pull request
Mar 23, 2026
…quences PR microsoft#302526 introduced automatic bracketed paste for any text containing `\r` or `\n`. This unintentionally changed the behavior of `sendText(text, false)` for control sequences such as `\u000D`, which could previously be sent as raw keystrokes via the `workbench.action.terminal.sendSequence` command to simulate Enter. This patch restores the original behavior by applying automatic bracketed paste only when: - explicitly requested via `bracketedPasteMode`, or - the text is multiline *and* `shouldExecute` is true This preserves the multiline execution fix while keeping non-executed control sequences raw. A regression test is included to verify that `sendText('\r', false)` sends a plain `\r` to the pty instead of wrapping it in bracketed paste. Fixes microsoft#303665
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Why This Is Required
Multiline executed text is currently sent as raw keystrokes unless the caller explicitly requests bracketed paste. That transport is incorrect for multiline payloads: embedded newlines behave like Enter, shell line editing can interfere, and repeated runs can corrupt the command or leave the shell stuck in a continuation prompt.
Applying bracketed paste automatically for multiline executed text fixes that mismatch while keeping the existing explicit API behavior intact.
Current Symptoms
The current behavior shows up as one or more of the following when the same multiline payload is executed repeatedly in a live terminal session:
quote>or another continuation promptA representative repro is prompting the following twice.
Expected:
Observed in failing cases:
1064Integration Test Coverage
This change is exercised in the dedicated integration test repo:
The workflow runs the repro suite against:
Workflow file:
The suite covers:
executeCommandandsendTextbashandzshon Unix-like runnerspwshand Git Bash on WindowsMost Recent Workflow Results
Latest completed run:
Per-job results:
ubuntu-latest / VS Code stable: 16 passed, 0 failed, 0 skippedubuntu-latest / VS Code insiders: 16 passed, 0 failed, 0 skippedubuntu-latest / VS Code PR: 16 passed, 0 failed, 0 skippedmacos-latest / VS Code stable: 3 passed, 13 failed, 0 skippedmacos-latest / VS Code insiders: 4 passed, 12 failed, 0 skippedmacos-latest / VS Code PR: 16 passed, 0 failed, 0 skippedwindows-latest / VS Code stable: 15 passed, 1 failed, 0 skippedwindows-latest / VS Code insiders: 16 passed, 0 failed, 0 skippedwindows-latest / VS Code PR: 16 passed, 0 failed, 0 skippedThe important signal from this run is:
executeCommand5x with the 40-line payloadpwshand Git BashPlatform Scope
This should not be limited to macOS.
macOS still provides the clearest baseline reproduction, but the new Windows matrix shows the issue is not macOS-specific. On Windows stable,
pwshis clean while Git Bash still reproduces a multiline execution failure. That is consistent with this being an input-path mismatch that depends on shell behavior and bracketed paste support, not a macOS-only bug.The latest integration results support applying the fix broadly wherever bracketed paste mode is supported:
Given that the change corrects a general terminal input-path mismatch, and given that the cross-platform integration results are clean for the PR build, the setting should apply wherever bracketed paste mode is supported rather than being special-cased to macOS.
Fixes #296955
Fixes #300762