Score adjustment for a match that is closer to the start of string #1516
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.
Context
Currently scoring is the same regardless of the position of the matched string, e.g. 'hello world' and 'world hello' have the same score. This change adds an adjustment during score calculation to allow 'world hello' to score higher than 'hello world' when query is 'world'.
How
The conditions for this adjustment to kick in is:
Score adjustment is done by:
Counting the number of spaces from the start of the string and deduct this from the score. So when matching 'world', 'world hello' has 0 spaces, so nothing is deducted from the score. On the other hand 'crazy on fire world' has three spaces so deduct three from the score.
Some pretty pictures
Before, notice 'Graphics Settings' should be higher:

After:

What's tested