Support for RTL text in find decorations#314872
Open
kamyarmg wants to merge 3 commits intomicrosoft:mainfrom
Open
Support for RTL text in find decorations#314872kamyarmg wants to merge 3 commits intomicrosoft:mainfrom
kamyarmg wants to merge 3 commits intomicrosoft:mainfrom
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates the editor Find match decorations to preserve correct visual ordering in mixed LTR/RTL lines by avoiding inline styling (which can split bidi runs and cause incorrect rendering). It also adds a browser-level FindModel test to validate the RTL-aware behavior.
Changes:
- Introduces RTL-aware selection of find match decoration options (regular/current match), falling back to non-inline decorations on lines containing RTL text.
- Adds new “bidi” decoration option variants that omit
inlineClassNamewhile keeping existing find match visuals (className/overview ruler/minimap). - Adds a test ensuring mixed LTR/RTL lines avoid inline styling while LTR-only lines keep the existing inline styling.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| src/vs/editor/contrib/find/browser/findDecorations.ts | Adds RTL detection and new bidi-safe decoration options; switches find match/current match decorations based on RTL presence. |
| src/vs/editor/contrib/find/test/browser/findModel.test.ts | Adds coverage for RTL-aware decoration selection (inline vs non-inline styling). |
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.
Summary
Fixes incorrect visual ordering when Find highlights matches inside mixed LTR/RTL text.
In lines containing RTL text, Find no longer applies inline styling that splits the rendered content into multiple bidi runs. Instead, it uses decorations that preserve the correct visual ordering of highlighted text.
Fixes #233573.
Problem
When Find highlights a match inside a line containing mixed LTR and RTL text, the highlight can split the rendered content into multiple inline segments.
In some cases, this changes the visual ordering of the RTL portion of the line, causing highlighted matches to appear with characters in the wrong order even though the underlying text is correct.
Root Cause
Find match decorations relied on inline text styling.
While this works correctly for normal LTR text, applying inline styling inside mixed bidi content can split a visual bidi run into separate segments. Once split, browser bidi layout may reorder the segments visually, making the highlighted substring appear incorrect.
Fix
This change makes Find match decorations aware of RTL content.
This preserves Find highlighting while avoiding the bidi run splitting that caused incorrect visual ordering.
Screenshots
Original Text
Before
After
How to Test