View source
class SimpleWeightedCompletionMatcher
package moonshine.editor.text.lsp.managers.completion
implements ICompletionMatcher
Calculates a weight value for each CompletionItem
, and sorts by weight.
Filtering:
- Case-insensitive. Calls `toLowerCase() on all text.
- The first character of the filter text must match the first character of
the
CompletionItem
text. - The
CompletionItem
text must contain every character from the filter text, in order, but the characters don't need to be consecutive.
Sorting:
- Sorts by weight, ascending.
- A weight value of 0 is a perfect match.
- For every character in the
CompletionItem
text that is skipped, and for every remaining character after the filter text is exhausted, the weight increases by one. - If two weight values match, falls back case-insensitive string comparison.