fix: selection of string literals when string contains escape characters#295302
Merged
benvillalobos merged 5 commits intomicrosoft:mainfrom Feb 14, 2026
Merged
fix: selection of string literals when string contains escape characters#295302benvillalobos merged 5 commits intomicrosoft:mainfrom
benvillalobos merged 5 commits intomicrosoft:mainfrom
Conversation
dmitrivMS
previously approved these changes
Feb 14, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes double-click string selection when a string literal is tokenized into multiple adjacent StandardTokenType.String tokens (e.g., around escapes / punctuation), so selecting at the quote boundary selects the full string content as expected (issue #292784).
Changes:
- Expand
_trySelectStringContentto treat consecutive adjacentStringtokens as a single logical string span. - Add a regression test for selecting string content when escape sequences cause token splits.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
src/vs/editor/browser/view/viewController.ts |
Updates string-content selection logic to merge adjacent string tokens into one selection span. |
src/vs/editor/test/browser/view/viewController.test.ts |
Adds a regression test covering escape-driven token splitting during string selection. |
Comments suppressed due to low confidence (1)
src/vs/editor/test/browser/view/viewController.test.ts:321
- The token layout comment says the String token spans
[8..22), but the provided tokens are intentionally split at 14 and 16. Updating the comment to describe the split segments (or removing the combined-range annotation) would make the test easier to understand and maintain.
// Token layout: [0..8) Other [8..22) String("hello\"world") [22..23) Other
const controller = createViewControllerWithTokens(text, [
{ startIndex: 0, type: StandardTokenType.Other },
{ startIndex: 8, type: StandardTokenType.String },
{ startIndex: 14, type: StandardTokenType.String },
{ startIndex: 16, type: StandardTokenType.String },
{ startIndex: 22, type: StandardTokenType.Other },
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Contributor
|
@RedCMD please address the comments. |
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Contributor
Author
|
@dmitrivMS done. |
dmitrivMS
approved these changes
Feb 14, 2026
benvillalobos
approved these changes
Feb 14, 2026
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.
fixes #292784
merges multiple string tokens together
because escape characters and quote characters (with certain themes on) were separate tokens
"hello\"world"double click after first quote
", beforehbefore:

after:

cc @dmitrivMS