Search-in-Files Result Navigation Highlight
January 17, 2026 · View on GitHub
Overview
When navigating to a search-in-files result, the editor now:
- Opens the file (or switches to existing tab)
- Switches to Raw mode (if in Rendered mode)
- Scrolls to the exact match location
- Applies a temporary visual highlight on the matched text
- Positions the cursor at the match location
Transient Highlight Behavior
The highlight is temporary and automatically disappears when:
- Scroll: User scrolls the editor (except the initial programmatic scroll)
- Edit: Any text edit occurs in the document
- Click: Any mouse click in the editor area
This prevents visual clutter and ensures the highlight is only visible when useful.
Implementation Details
Key Components
SearchNavigationTarget (src/ui/search.rs)
Contains all information needed for navigation:
path: File path to openline_number: Line number (1-indexed) for scroll positioningchar_offset: Absolute character offset from document startmatch_len: Length of the matched text
TransientHighlight (src/state.rs)
Manages the transient highlight state:
range: Option<(usize, usize)>: Character range to highlightignore_next_scroll: bool: Guard flag for programmatic scroll- Methods:
set(),clear(),on_scroll(),on_edit(),on_click()
Tab Methods (src/state.rs)
Helper methods on Tab struct:
set_transient_highlight(start, end)clear_transient_highlight()has_transient_highlight()transient_highlight_range()on_scroll_event(),on_edit_event(),on_click_event()
EditorWidget (src/editor/widget.rs)
Renders the transient highlight:
.transient_highlight(range)builder method- Distinct amber/orange color (different from search and selection)
- Supports single-line and multi-line highlights
Flow
- User clicks search result in Search-in-Files panel
SearchPanelOutput.navigate_tois set withSearchNavigationTargethandle_search_navigation()in app.rs:- Opens/switches to file
- Switches to Raw mode if needed
- Sets transient highlight via
tab.set_transient_highlight() - Sets cursor position
- Schedules scroll via
pending_scroll_to_line
- EditorWidget renders highlight with amber color
- Highlight cleared on scroll/edit/click via event handlers
Colors
The transient highlight uses a distinct amber/orange color to differentiate from:
- Find/Replace highlights: Yellow
- Text selection: Theme-dependent blue
- Multi-cursor selections: Light blue
| Mode | Color |
|---|---|
| Dark | rgba(255, 165, 50, 120) - Amber |
| Light | rgba(255, 180, 80, 150) - Light orange |
Testing
Manual test cases:
- Click search result in open file → verify scroll + highlight
- Click result in closed file → verify file opens, scrolls, highlights
- Scroll after highlight → verify highlight disappears
- Edit after highlight → verify highlight disappears
- Click anywhere after highlight → verify highlight disappears
- Click multiple results → verify only one highlight at a time
- In Rendered mode, click result → verify switch to Raw mode + highlight