Skip to content

feat(search): highlight a found line by meaning, without the query's words - #132

Merged
kdroidFilter merged 1 commit into
masterfrom
feat/semantic-highlight-everywhere
Oct 12, 2026
Merged

kdroidFilter merged 1 commit into
masterfrom
feat/semantic-highlight-everywhere

Conversation

@kdroidFilter

Copy link
Copy Markdown
Owner

Engines that search by meaning now highlight a search the way the meaning finds it: in the found line alone, the passage closest in meaning, and none of the query's words. An exact (quoted) query, and engines without a meaning search (LuceneSearchEngine alone), keep highlighting the words, unchanged.

Changes

  • SearchEngine.highlightsByMeaning(query): which rule applies, false by default. highlights() follows it: the passage alone, or the words. The alwaysByMeaning parameter is gone (one rule for results, preview and smart find).
  • LineHit.lineStart / lineEnd: where the hit line is in its snippet source, as a short line's snippet carries its neighbors. The passage is sought in the found line, not in them. Defaults cover the whole rawText, so existing callers are unaffected.
  • rangeSnippet(text, ranges, lineStart, lineEnd): the snippet is laid out on the hit line.

The meaning search itself (passage selection) stays in the semantic addon; this PR only adds the generic hooks.

Tests

HighlightsTest covers both rules: passage alone (whole line for a single clause, nothing for a blank line), and a quoted query keeping its words. :search:jvmTest: 116 tests pass.

…words

Engines that search by meaning now highlight a search the way the meaning
finds it: in the found line alone, the passage closest in meaning, and none of
the query's words. An exact (quoted) query, and engines without a meaning
search, keep the words.

- SearchEngine.highlightsByMeaning(query) tells which rule applies (false by
  default), and highlights() follows it: the passage alone, or the words.
- LineHit keeps where the hit line is in its snippet source (lineStart,
  lineEnd), as a short line's snippet carries its neighbors: the passage is
  sought in the found line, not in them.
- rangeSnippet takes those bounds, so the snippet is laid out on the hit line.

Signed-off-by: Elie Gambache <elyahou.hadass@gmail.com>
@kdroidFilter
kdroidFilter merged commit c3190c4 into master Oct 12, 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.

1 participant