mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-01 22:31:43 +00:00
feat: always prefer postfix snippets if there's exact textual match
Note that, while we don't currently have a fuzzy-matching score, it makes sense to special-case postfix templates -- it's very annoying when `.not()` gets sorted before `.not`. We might want to move this infra to fuzzy matching, once we have that!
This commit is contained in:
parent
030217d573
commit
fbb9d69758
4 changed files with 105 additions and 23 deletions
|
@ -15,7 +15,7 @@ use crate::{
|
|||
context::CompletionContext,
|
||||
item::{Builder, CompletionKind},
|
||||
patterns::ImmediateLocation,
|
||||
CompletionItem, CompletionItemKind, Completions,
|
||||
CompletionItem, CompletionItemKind, CompletionRelevance, Completions,
|
||||
};
|
||||
|
||||
pub(crate) fn complete_postfix(acc: &mut Completions, ctx: &CompletionContext) {
|
||||
|
@ -299,6 +299,12 @@ fn postfix_snippet(
|
|||
};
|
||||
let mut item = CompletionItem::new(CompletionKind::Postfix, ctx.source_range(), label);
|
||||
item.detail(detail).kind(CompletionItemKind::Snippet).snippet_edit(cap, edit);
|
||||
if ctx.original_token.text() == label {
|
||||
let mut relevance = CompletionRelevance::default();
|
||||
relevance.exact_postfix_snippet_match = true;
|
||||
item.set_relevance(relevance);
|
||||
}
|
||||
|
||||
item
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue