Skip to content

Fuzzy find with highlighting#62

Merged
rgwood merged 1 commit intomasterfrom
fuzzy-find
Jan 11, 2026
Merged

Fuzzy find with highlighting#62
rgwood merged 1 commit intomasterfrom
fuzzy-find

Conversation

@rgwood
Copy link
Copy Markdown
Owner

@rgwood rgwood commented Dec 28, 2025

Improving the find/search functionality.

Copy link
Copy Markdown

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

This PR adds fuzzy find functionality with match highlighting to the search feature. Users can now see matched characters highlighted (bold + underlined) when searching for systemd units, and search results are sorted by relevance score.

  • Introduces MatchedUnit struct to wrap units with their fuzzy match indices for highlighting
  • Replaces simple substring matching with fuzzy matching using the fuzzy-matcher crate (SkimMatcherV2)
  • Updates the UI rendering to highlight matched characters in the service list

Reviewed changes

Copilot reviewed 2 out of 3 changed files in this pull request and generated 1 comment.

File Description
src/components/home.rs Adds MatchedUnit struct, updates filtered_units to use it, implements fuzzy matching in refresh_filtered_units(), adds highlighting logic in the render method, and updates all references to access .unit field
Cargo.toml Adds fuzzy-matcher = "0.3" dependency
Cargo.lock Adds lock file entries for fuzzy-matcher and its dependency thread_local

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/components/home.rs
let mut last_end = 0;

for &idx in &m.match_indices {
if idx > last_end && idx <= name.len() {
Copy link

Copilot AI Dec 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The condition idx <= name.len() should be idx < name.len(). When idx == name.len(), we're at the end of the string and shouldn't be processing a match at that position. This could lead to incorrect highlighting if the fuzzy matcher returns an out-of-bounds index.

Suggested change
if idx > last_end && idx <= name.len() {
if idx > last_end && idx < name.len() {

Copilot uses AI. Check for mistakes.
@rgwood rgwood merged commit fca428c into master Jan 11, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants