fix(preview): highlight all matches per file in grep preview#559
Open
gustav-fff wants to merge 1 commit into
Open
fix(preview): highlight all matches per file in grep preview#559gustav-fff wants to merge 1 commit into
gustav-fff wants to merge 1 commit into
Conversation
Closes #555 (step 2). picker_ui collects every loaded match for the previewed file and forwards them as location.file_matches. location_utils highlights each range using the byte offsets ripgrep / fuzzy traceback already provide, so plain, regex, and fuzzy modes all light up every hit at once.
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.
Closes #555 (step 2). Step 1 already shipped in #556.
Root cause
location_utils.highlight_grep_matchesonly highlighted the cursor's match line. In fuzzy mode it explicitly returned after that line; in plain/regex it scanned ±200 lines viastring.find, which still missed any match the cursor wasn't parked on (no per-line range visibility).Fix
Plumb every loaded match for the previewed file from picker_ui through
location.file_matches = { {line, ranges}, ... }, then highlight each range using ripgrep-supplied byte offsets (match_byte_offsetsin Rust →match_rangesin Lua). Same path covers plain, regex, and fuzzy — all three populate the offsets incrates/fff-core/src/grep.rs:272. Falls back to the existing literal scan whenfile_matchesis absent.lua/fff/picker_ui.lua:1443collects matches sharingrelative_path.lua/fff/location_utils.lua:152consumes them.Steps to reproduce
Then
:FFFFind, switch to grep mode, type a query that hits the same file on multiple lines (e.g.function).How verified
make lint(rust). Lua linter is broken locally (missing/opt/homebrew/opt/lua/bin/lua5.4); change is mechanical Lua and structurally mirrors the existing fuzzy path that already shipped in #556.Automated triage via Gustav. Honk-Honk 🪿