editor: Utilize filter_text from language server for filter_range (#33155)
Closes #33106 Instead of directly using `filter_text` in `StringMatchCandidate`, which yields better results for fuzzy matching but messes up with highlighting letters in bold, as `positions` list generated by fuzzy crate are now of `filter_text` and not `label` shown to the user. This PR fixes it by keeping use of `filter_range` in `StringMatchCandidate`, which is range w.r.t to `label` shown to user. And actually generating this `filter_range` at source by using `filter_range` if exists. - [x] Tests Release Notes: - Fixed issue where incorrect letters are marked as bold in completions.
This commit is contained in:
@@ -260,7 +260,7 @@ impl CompletionsMenu {
|
||||
let match_candidates = completions
|
||||
.iter()
|
||||
.enumerate()
|
||||
.map(|(id, completion)| StringMatchCandidate::new(id, completion.filter_text()))
|
||||
.map(|(id, completion)| StringMatchCandidate::new(id, completion.label.filter_text()))
|
||||
.collect();
|
||||
|
||||
let completions_menu = Self {
|
||||
@@ -1115,7 +1115,7 @@ impl CompletionsMenu {
|
||||
SnippetSortOrder::Inline => Reverse(0),
|
||||
};
|
||||
let sort_positions = string_match.positions.clone();
|
||||
let sort_exact = Reverse(if Some(completion.filter_text()) == query {
|
||||
let sort_exact = Reverse(if Some(completion.label.filter_text()) == query {
|
||||
1
|
||||
} else {
|
||||
0
|
||||
|
||||
Reference in New Issue
Block a user