This repository has been archived by the owner on Sep 7, 2023. It is now read-only.
Ignore double-quotes when highlighting query parts #2553
Merged
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.
What does this PR do?
This is to fix a minor UI bug where using a search with an exact phrase in quotes wouldn't highlight the matching phrase in the search results. This replaces #901 which I'll close.
For example:
search:
master of none
result: master of none
search:
"master of none"
result: master of none
The cause of this bug is that a query like
"master of none"
gets split into['"master', 'of', 'none"']
, and the code tries to highlight strings likenone"
which aren't typically in the text. This change works by ignoring double quotes in the query. I added test coverage for other paths through thewebutils.highlight_content
function. Currently there are no tests that cover the scenario where there needs to bespan
elements inserted in the result.Why is this change important?
Without this change, only the interior parts of a phrase in quotes will be highlighted. In many cases that might be the least important words of the phrase and it's surprising behavior to a user.
How to test this PR locally?
The unit tests for this function pass and to test manually, you can search for several queries, first without quotation marks, and then with them, and the highlighted words in the results should be the same.
Author's checklist
I considered pulling the existing test cases in to the new
data
tuple in the unit test, but I decided it was useful to keep them separate because they're all testing edge cases or cases where no highlights would be inserted.