Repository navigation
feat(search): highlight a found line by meaning, without the query's words - #132
Merged
Merged
Conversation
…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>
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.
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 (
LuceneSearchEnginealone), keep highlighting the words, unchanged.Changes
SearchEngine.highlightsByMeaning(query): which rule applies,falseby default.highlights()follows it: the passage alone, or the words. ThealwaysByMeaningparameter 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 wholerawText, 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
HighlightsTestcovers 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.