Skip to content

feat(search): shared "search in page" across file viewer, diff viewer & content-search preview#147

Merged
matej21 merged 1 commit into
mainfrom
feat/in-page-search
Jun 19, 2026
Merged

feat(search): shared "search in page" across file viewer, diff viewer & content-search preview#147
matej21 merged 1 commit into
mainfrom
feat/in-page-search

Conversation

@matej21

@matej21 matej21 commented Jun 18, 2026

Copy link
Copy Markdown
Member

Context

Okena renders file/text content line-by-line in three places, but only one let you find text inside it:

View Renders content In-page find (Cmd/Ctrl+F) before
File viewer yes yes
Git diff viewer (unified + side-by-side) yes no
Content Search dialog preview pane yes no

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)

  • InPageSearch engine: searches a flat list of host-defined cells (text + opaque usize id), tracks the current match, navigation, case toggle, and theme-colored ranges_for_cell(). The host owns all view semantics (what a cell maps to, how to scroll to it).
  • Generic render_search_bar<V> + SearchBarCallbacks<V>: the full bar (input, Aa case toggle, n/N counter, 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 root Cancel handler (which closes search first).

Hosts

  • 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 (expanders get an empty cell so indices line up with the 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.
  • Content Search dialog — in-page search over the preview pane (Cmd/Ctrl+F), layered on top of the existing grep-match highlights.

Verification

  • cargo build --workspace — OK (incl. the okena binary and okena-app)
  • cargo test --workspace — all pass, 0 failures
  • cargo clippy -p okena-files -p okena-views-git — clean

Manual GUI verification of the three views (interactive find/highlight/scroll, both diff layouts) still recommended.

🤖 Generated with Claude Code

… & 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
@matej21 matej21 merged commit a71e1d5 into main Jun 19, 2026
8 checks passed
@matej21 matej21 deleted the feat/in-page-search branch June 19, 2026 12:22
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.

1 participant