Skip to content

Feat/search highlight - #15

Open
hadoukim wants to merge 3 commits into
Walkercito:mainfrom
hadoukim:feat/search-highlight
Open

hadoukim wants to merge 3 commits into
Walkercito:mainfrom
hadoukim:feat/search-highlight

Conversation

@hadoukim

@hadoukim hadoukim commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

What does this PR do?

Builds on #14 — please merge that one first; this branch contains its commit.

With a search active, a card now shows where it matches: the hit is painted bold on a translucent yellow, like a find-in-page match. Long clips no longer leave you guessing which part of their text answered the query, and a subsequence match shows the scattered letters that made it.

  • match_mask() (next to match_quality(), headless) returns the bytes to highlight: every verbatim occurrence of the query, else the in-order characters of the subsequence match. match_quality() now shares its subsequence scan.
  • ClipCard::set_query() applies the highlight to the shown text (collapsed preview or expanded clip) as Pango attributes. Case is folded per code point and hits are mapped back onto the original bytes, so a highlight never splits a character, even where lowercasing changes a character's byte length.
  • MainWindow::apply_filter() passes the query to each card; clearing the search clears the highlight.

Type of change

  • Bug fix
  • New feature
  • Refactor / cleanup
  • Docs
  • Build / CI

Checklist

  • The build is clean — warnings are errors (-Werror).
  • ctest --preset debug passes.
  • The sanitizer build passes: cmake --build --preset asan && ctest --preset asan (zero leaks, zero UB).
  • clang-format and clang-tidy are clean.
  • Commits follow Conventional Commits, with no AI/assistant trailers.
  • A change to core/ ships with tests. (No core/ change; FuzzyTest covers match_mask().)
  • Docs (README / CONTRIBUTING) updated if behavior changed.

Notes for reviewers

  • Highlight colour is GNOME palette yellow 3 (#f6d32d) at 40 % alpha, readable on both light and dark themes.
  • The expanded text now goes through make_valid_utf8() like the preview already did, so the label never receives invalid UTF-8.
  • Known limit: multi-character case foldings (ß ↔ SS) are not highlighted; filtering is unaffected since it folds whole strings.
  • clang-tidy was run locally with 22.1 (18.1.8 cannot parse GCC 16's libstdc++): no new findings beyond the readability-trailing-comma style CI's 18.1.8 does not have.

The fuzzy filter accepts any clip that spells the query out of scattered
letters, so long clips match almost anything and, kept in history order,
bury the clip that holds the query verbatim. Rank matches instead: a
contiguous run sorts above a scattered subsequence, and a new query puts
the cursor on its best match so Enter pastes it.
With a query active, each card paints where it matches: every verbatim
occurrence, or the scattered characters of a subsequence match. Users
see at a glance why a clip came up, and long clips no longer hide the
hit somewhere in their text.

match_mask() computes the hit bytes headless, next to match_quality();
the card folds case per code point and maps hits back onto the shown
text, so a highlight never splits a character.
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