Skip to content

terminal: fix type-ahead prediction incorrectly rejecting valid style sequences - #305103

Merged
Connor Peet (connor4312) merged 4 commits into
microsoft:mainfrom
xingsy97:wt/terminal-typeahead-index
Nov 3, 2026
Merged

Connor Peet (connor4312) merged 4 commits into
microsoft:mainfrom
xingsy97:wt/terminal-typeahead-index

Conversation

@xingsy97

Copy link
Copy Markdown
Member

Problem

arrayHasPrefixAt(a, ai, b) in terminalTypeAheadAddon.ts checks whether array a starting at position ai begins with array b. The comparison loop uses b[ai] instead of b[bi] to index into the second array. When ai > 0, this reads the wrong position in b; when ai >= b.length, b[ai] is always undefined and the check silently fails.

The function is used in TypeAheadStyle._onDidWriteSGR to match incoming SGR sequences against expected undo/apply arguments. When the match starts past index 0 in the args array, the style tracker fails to recognize its own sequences, causing incorrect style restoration during terminal type-ahead prediction.

Fix

Change b[ai] to b[bi] in the comparison loop.

Copilot AI review requested due to automatic review settings March 26, 2026 10:03
@vs-code-engineering vs-code-engineering Bot added this to the 1.114.0 milestone Mar 26, 2026
@alexr00 Alex Ross (alexr00) removed this from the 1.114.0 milestone Mar 30, 2026

@connor4312 Connor Peet (connor4312) left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

thanks!

@connor4312
Connor Peet (connor4312) enabled auto-merge (squash) November 3, 2026 19:58

@TylerLeonhardt TylerLeonhardt left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

no tests?

auto-merge was automatically disabled November 3, 2026 22:19

Pull request was closed

@connor4312
Connor Peet (connor4312) enabled auto-merge (squash) November 3, 2026 22:19
@vs-code-engineering

Copy link
Copy Markdown
Contributor

📬 CODENOTIFY

The following users are being notified based on files changed in this PR:

Anthony Kim (@anthonykim1)

Matched files:

  • src/vs/workbench/contrib/terminalContrib/typeAhead/browser/terminalTypeAheadAddon.ts

@connor4312
Connor Peet (connor4312) merged commit cbc03c7 into microsoft:main Nov 3, 2026
59 checks passed
@vs-code-engineering vs-code-engineering Bot added this to the 1.146.0 milestone Nov 3, 2026
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.

7 participants