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:
parent
834cdc1271
commit
76e3136369
10 changed files with 206 additions and 61 deletions
|
@ -264,11 +264,7 @@ impl CompletionBuilder {
|
|||
Completion {
|
||||
replace_range: Anchor::MIN..Anchor::MAX,
|
||||
new_text: label.to_string(),
|
||||
label: CodeLabel {
|
||||
text: label.to_string(),
|
||||
runs: Default::default(),
|
||||
filter_range: 0..label.len(),
|
||||
},
|
||||
label: CodeLabel::plain(label.to_string(), filter_text),
|
||||
documentation: None,
|
||||
source: CompletionSource::Lsp {
|
||||
insert_range: None,
|
||||
|
@ -299,7 +295,7 @@ async fn filter_and_sort_matches(
|
|||
let candidates: Arc<[StringMatchCandidate]> = completions
|
||||
.iter()
|
||||
.enumerate()
|
||||
.map(|(id, completion)| StringMatchCandidate::new(id, &completion.filter_text()))
|
||||
.map(|(id, completion)| StringMatchCandidate::new(id, &completion.label.filter_text()))
|
||||
.collect();
|
||||
let cancel_flag = Arc::new(AtomicBool::new(false));
|
||||
let background_executor = cx.executor();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue