feat(search): shared "search in page" across file viewer, diff viewer & content-search preview#147
Merged
Merged
Conversation
… & content-search preview Extract the file viewer's in-file find into a shared, view-agnostic engine (okena-files/in_page_search) and drive all three content viewers from it: - New InPageSearch engine: searches a flat list of host-defined "cells" (text + opaque id), tracks the current match, navigation, case toggle, and theme-colored highlight ranges. Plus a generic render_search_bar<V> + callbacks (input, "Aa" toggle, n/N counter, prev/next, close). - File viewer: refactored onto the shared engine (behavior-preserving; also unifies the previously hardcoded highlight colors onto theme colors). - Git diff viewer: in-page search added for both unified and side-by-side layouts. Cell scheme: unified = item index; side-by-side = row*2 + side. Matches recompute on file switch / view-mode toggle / whitespace / query. - Content Search dialog: in-page search over the preview pane (Cmd/Ctrl+F). Escape flows to each host's existing root Cancel handler (closes search first); the bar handles Enter/Shift+Enter and stops key propagation so typed keys don't leak into host shortcuts. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01Cvca6jmiJhjLTWGSuAnCEy
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.
Context
Okena renders file/text content line-by-line in three places, but only one let you find text inside it:
The file viewer's find lived entirely inside
impl FileViewer(~340 lines, ~130 of which was the search-bar UI). Copying it twice would triple the bug surface and the UI drift — already visible in an inconsistency: the file viewer hardcoded its highlight colors while the content-search preview already read theme colors.What this does
Extracts the find logic + search-bar UI into one shared, view-agnostic module and drives all three viewers from it.
Shared module —
crates/okena-files/src/in_page_search.rs(new)InPageSearchengine: searches a flat list of host-defined cells (text + opaqueusizeid), tracks the current match, navigation, case toggle, and theme-coloredranges_for_cell(). The host owns all view semantics (what a cell maps to, how to scroll to it).render_search_bar<V>+SearchBarCallbacks<V>: the full bar (input,Aacase toggle,n/Ncounter, prev/next, close). Handles Enter / Shift+Enter and stops key propagation so typed keys never leak into host shortcuts; Escape flows to each host's existing rootCancelhandler (which closes search first).Hosts
uniform_list); side-by-side =row*2 + side, scroll item =cell / 2. Matches recompute on file switch / view-mode toggle / whitespace toggle / query / case change via a signature check.Verification
cargo build --workspace— OK (incl. theokenabinary andokena-app)cargo test --workspace— all pass, 0 failurescargo clippy -p okena-files -p okena-views-git— cleanManual GUI verification of the three views (interactive find/highlight/scroll, both diff layouts) still recommended.
🤖 Generated with Claude Code