eval: prefer longer candidateMatch when removing overlaps #727
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.
When thinking about transforming queries like 'foo bar' into '(foo bar) or "foo bar"' we would want to keep the phrase candidateMatch and not throw it away in gatherMatches. By sorting longer matches before others that start at the same offset we end up keeping those.
Note: this only affects ChunkMatch, since for LineMatch we merge when we find overlaps.
Test Plan: This was quite hard to test with our existing e2e tests due to them not recording offsets, only matching lines. So instead I am just relying on the fact we didn't break anything and once we add proper support for phrases we will have a test then.