Merge #11886
11886: add test for postfix completion relevance r=matklad a=matklad Follow up to #11857, add a test and cov-marks bors r+ 🤖 Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
This commit is contained in:
commit
f6bf7a3e41
@ -243,8 +243,10 @@ fn build_postfix_snippet_builder<'ctx>(
|
|||||||
CompletionItem::new(CompletionItemKind::Snippet, ctx.source_range(), label);
|
CompletionItem::new(CompletionItemKind::Snippet, ctx.source_range(), label);
|
||||||
item.detail(detail).snippet_edit(cap, edit);
|
item.detail(detail).snippet_edit(cap, edit);
|
||||||
let postfix_match = if ctx.original_token.text() == label {
|
let postfix_match = if ctx.original_token.text() == label {
|
||||||
|
cov_mark::hit!(postfix_exact_match_is_high_priority);
|
||||||
Some(CompletionRelevancePostfixMatch::Exact)
|
Some(CompletionRelevancePostfixMatch::Exact)
|
||||||
} else {
|
} else {
|
||||||
|
cov_mark::hit!(postfix_inexact_match_is_low_priority);
|
||||||
Some(CompletionRelevancePostfixMatch::NonExact)
|
Some(CompletionRelevancePostfixMatch::NonExact)
|
||||||
};
|
};
|
||||||
let relevance = CompletionRelevance { postfix_match, ..Default::default() };
|
let relevance = CompletionRelevance { postfix_match, ..Default::default() };
|
||||||
|
@ -1550,7 +1550,8 @@ fn foo() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn postfix_completion_relevance() {
|
fn postfix_exact_match_is_high_priority() {
|
||||||
|
cov_mark::check!(postfix_exact_match_is_high_priority);
|
||||||
check_relevance_for_kinds(
|
check_relevance_for_kinds(
|
||||||
r#"
|
r#"
|
||||||
mod ops {
|
mod ops {
|
||||||
@ -1585,4 +1586,33 @@ fn main() {
|
|||||||
"#]],
|
"#]],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn postfix_inexact_match_is_low_priority() {
|
||||||
|
cov_mark::check!(postfix_inexact_match_is_low_priority);
|
||||||
|
check_relevance_for_kinds(
|
||||||
|
r#"
|
||||||
|
struct S;
|
||||||
|
impl S {
|
||||||
|
fn f(&self) {}
|
||||||
|
}
|
||||||
|
fn main() {
|
||||||
|
S.$0
|
||||||
|
}
|
||||||
|
"#,
|
||||||
|
&[CompletionItemKind::Snippet, CompletionItemKind::Method],
|
||||||
|
expect![[r#"
|
||||||
|
me f() []
|
||||||
|
sn ref []
|
||||||
|
sn refm []
|
||||||
|
sn match []
|
||||||
|
sn box []
|
||||||
|
sn dbg []
|
||||||
|
sn dbgr []
|
||||||
|
sn call []
|
||||||
|
sn let []
|
||||||
|
sn letm []
|
||||||
|
"#]],
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user