diff --git a/crates/editor/src/code_context_menus.rs b/crates/editor/src/code_context_menus.rs index 2c826068462b634e4d4fdaaa8ac838fa7e9a37e8..f129eaa617ef163fffe94ae9cd020b4df20fb587 100644 --- a/crates/editor/src/code_context_menus.rs +++ b/crates/editor/src/code_context_menus.rs @@ -160,12 +160,7 @@ impl CompletionsMenu { let match_candidates = completions .iter() .enumerate() - .map(|(id, completion)| { - StringMatchCandidate::new( - id, - &completion.label.text[completion.label.filter_range.clone()], - ) - }) + .map(|(id, completion)| StringMatchCandidate::new(id, &completion.label.filter_text())) .collect(); Self { diff --git a/crates/language/src/language.rs b/crates/language/src/language.rs index e0cd392131105c5104790d15adcd8697eb8d3753..ec49185d6b1e00b6e838624048ea79b53946ee93 100644 --- a/crates/language/src/language.rs +++ b/crates/language/src/language.rs @@ -1678,6 +1678,10 @@ impl CodeLabel { pub fn text(&self) -> &str { self.text.as_str() } + + pub fn filter_text(&self) -> &str { + &self.text[self.filter_range.clone()] + } } impl From for CodeLabel { diff --git a/crates/project_symbols/src/project_symbols.rs b/crates/project_symbols/src/project_symbols.rs index 49beeec478d8feef4aca1f08222f3880b4c35c07..a127f98392a6091a8080324e76f530fb5d0c141c 100644 --- a/crates/project_symbols/src/project_symbols.rs +++ b/crates/project_symbols/src/project_symbols.rs @@ -78,10 +78,7 @@ impl ProjectSymbolsDelegate { )); let sort_key_for_match = |mat: &StringMatch| { let symbol = &self.symbols[mat.candidate_id]; - ( - Reverse(OrderedFloat(mat.score)), - &symbol.label.text[symbol.label.filter_range.clone()], - ) + (Reverse(OrderedFloat(mat.score)), symbol.label.filter_text()) }; visible_matches.sort_unstable_by_key(sort_key_for_match); @@ -177,10 +174,7 @@ impl PickerDelegate for ProjectSymbolsDelegate { .iter() .enumerate() .map(|(id, symbol)| { - StringMatchCandidate::new( - id, - &symbol.label.text[symbol.label.filter_range.clone()], - ) + StringMatchCandidate::new(id, &symbol.label.filter_text()) }) .partition(|candidate| { project