Fix selection of string literals when clicking around quotes#294120
Merged
Fix selection of string literals when clicking around quotes#294120
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Improves the editor’s double-click “select string content” behavior near quotes by adding guard conditions to avoid incorrect selections caused by tokenizer/theme quirks and RTL edge cases, and adds targeted unit tests to cover the reported regressions.
Changes:
- Add stricter guards for string-content selection (boundary click, matching quote characters, RTL bail-out).
- Add a new test suite that simulates tokenization layouts to validate happy-path and bail-out scenarios.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| src/vs/editor/browser/view/viewController.ts | Tightens _trySelectStringContent heuristics to prevent broken selections for problematic tokenization/RTL cases. |
| src/vs/editor/test/browser/view/viewController.test.ts | Adds unit tests for string-content selection behavior across normal, theme-split-token, RTL, and brace-split scenarios. |
hediet
approved these changes
Feb 10, 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 #293384
Fixes #292784
Fixes #293203
String content selection on double-click uses tokenizer to detect string boundaries.
This approach is essentially a heuristic given tokens depend on the theme and language.
This PR adds some guards to the code to avoid broken scenarios since doing it properly would make code significantly more complicated without achieving 100% correctness lacking proper language support at this location.
If this proves insufficient, we may need to disable this functionality (for strings only, brackets are handled with a separate mechanism) and let language-specific extensions handle it if needed.