Repository navigation
fix(menu): map fallback highlights to original graphemes - #1303
Open
Rajatendu1 wants to merge 1 commit into
Open
Rajatendu1 wants to merge 1 commit into
Rajatendu1 wants to merge 1 commit into
Conversation
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
Fix Reedline's fallback completion highlighting when a completer does not supply
match_indices.get_match_indicessearches a lowercased string, wherefindreturns a UTF-8 byte offset.style_suggestionconsumes original grapheme indices. Passing that offset through shifts underlining after non-ASCII text, and lowercase expansions can shift it again.The change maps the matched lowercased byte range onto the original graphemes it overlaps. It keeps the existing whole-string lowercase search, leaves provided indices borrowed and unchanged, and keeps empty/no-match results empty. A substring that matches part of a displayed grapheme highlights that entire grapheme.
No public API signature changes. No new dependencies.
Related: nushell/nushell#17450. This fixes the Reedline fallback, not completion providers that compute their own indices.
Before
numéro.txtwith queryrounderlineso.. An emoji prefix can leave the match unhighlighted.After
The same query underlines
ro. Emoji, combining characters and lowercase length changes map back to the displayed text.Additional notes
18 added cases cover ASCII controls, accented/CJK/emoji prefixes, combining marks, CRLF, dotted-I expansion, Kelvin-sign contraction, contextual Greek lowercasing, empty/no match, explicit indices, and the actual styled output.
Local Linux validation with Rust 1.95.0, base 14be1e0:
cargo test --all-targets --all-features --locked: 2,330 library tests passed, 3 ignored; example test targets passed.cargo test --doc --all-features --locked: 32 passed.cargo nextest run --all --all-features: 2,330 passed, 3 skipped.cargo clippy --locked --all-targets --all-features -- -D warnings, formatting,git diff --check, and warning-free all-feature docs: passed.Not run: Windows/macOS or the full Nushell application. ANSI-decorated display-override matching and Unicode normalization/case-folding are unchanged and outside this patch.
Patch prepared and tests executed by Instinct, an AI assistant, at my request.