Skip to content

Fix selection of string literals when clicking around quotes#294120

Merged
dmitrivMS merged 5 commits intomainfrom
dev/dmitriv/string-double-click-fix
Feb 10, 2026
Merged

Fix selection of string literals when clicking around quotes#294120
dmitrivMS merged 5 commits intomainfrom
dev/dmitriv/string-double-click-fix

Conversation

@dmitrivMS
Copy link
Contributor

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.

@dmitrivMS dmitrivMS added this to the February 2026 milestone Feb 10, 2026
@dmitrivMS dmitrivMS requested a review from hediet February 10, 2026 12:36
@dmitrivMS dmitrivMS self-assigned this Feb 10, 2026
@dmitrivMS dmitrivMS added the editor-core Editor basic functionality label Feb 10, 2026
Copilot AI review requested due to automatic review settings February 10, 2026 12:36
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

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.

@dmitrivMS dmitrivMS merged commit c78a202 into main Feb 10, 2026
18 checks passed
@dmitrivMS dmitrivMS deleted the dev/dmitriv/string-double-click-fix branch February 10, 2026 23:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

editor-core Editor basic functionality

Projects

None yet

2 participants