Skip to content

fix(terminal): avoid auto bracketed paste for non-executed control sequences#303666

Open
kh4f wants to merge 2 commits intomicrosoft:mainfrom
kh4f:fix/terminal-sendsequence-cr
Open

fix(terminal): avoid auto bracketed paste for non-executed control sequences#303666
kh4f wants to merge 2 commits intomicrosoft:mainfrom
kh4f:fix/terminal-sendsequence-cr

Conversation

@kh4f
Copy link

@kh4f kh4f commented Mar 21, 2026

PR #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 #303665

…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
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR restores the pre-#302526 behavior for TerminalInstance.sendText(text, false) when sending control sequences (eg \r) by limiting automatic bracketed paste to explicitly requested cases or executed multiline input, preventing sendSequence regressions while keeping the multiline-execution fix.

Changes:

  • Restrict automatic bracketed paste wrapping to bracketedPasteMode === true or (shouldExecute && text contains newline chars), when bracketed paste is enabled in xterm.
  • Add a regression test ensuring sendText('\r', false) writes a raw \r rather than wrapping it 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 avoid bracketed paste wrapping for non-executed control sequences while preserving executed multiline behavior.
src/vs/workbench/contrib/terminal/test/browser/terminalInstance.test.ts Adds regression coverage verifying raw \r is sent when shouldExecute is false.

@kh4f
Copy link
Author

kh4f commented Mar 21, 2026

@microsoft-github-policy-service agree

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Integrated terminal: workbench.action.terminal.sendSequence no longer simulates Enter with \u000D in Git Bash

3 participants