Skip to content

Commit fe16e1d

Browse files
bors[bot]matklad
andauthored
Merge #5215
5215: Cleanup more completion tests r=matklad a=matklad bors r+ Co-authored-by: Aleksey Kladov <[email protected]>
2 parents f6bff05 + cda1a6c commit fe16e1d

File tree

3 files changed

+177
-331
lines changed

3 files changed

+177
-331
lines changed

crates/ra_ide/src/completion/complete_keyword.rs

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
//! FIXME: write short doc here
22
33
use ra_syntax::{ast, SyntaxKind};
4+
use test_utils::mark;
45

56
use crate::completion::{
67
CompletionContext, CompletionItem, CompletionItemKind, CompletionKind, Completions,
@@ -38,6 +39,7 @@ pub(super) fn complete_use_tree_keyword(acc: &mut Completions, ctx: &CompletionC
3839

3940
pub(super) fn complete_expr_keyword(acc: &mut Completions, ctx: &CompletionContext) {
4041
if ctx.token.kind() == SyntaxKind::COMMENT {
42+
mark::hit!(no_keyword_completion_in_comments);
4143
return;
4244
}
4345

@@ -180,6 +182,7 @@ mod tests {
180182
test_utils::{check_edit, completion_list},
181183
CompletionKind,
182184
};
185+
use test_utils::mark;
183186

184187
fn check(ra_fixture: &str, expect: Expect) {
185188
let actual = completion_list(ra_fixture, CompletionKind::Keyword);
@@ -459,4 +462,32 @@ fn quux() -> i32 {
459462
"#]],
460463
);
461464
}
465+
466+
#[test]
467+
fn no_keyword_completion_in_comments() {
468+
mark::check!(no_keyword_completion_in_comments);
469+
check(
470+
r#"
471+
fn test() {
472+
let x = 2; // A comment<|>
473+
}
474+
"#,
475+
expect![[""]],
476+
);
477+
check(
478+
r#"
479+
/*
480+
Some multi-line comment<|>
481+
*/
482+
"#,
483+
expect![[""]],
484+
);
485+
check(
486+
r#"
487+
/// Some doc comment
488+
/// let test<|> = 1
489+
"#,
490+
expect![[""]],
491+
);
492+
}
462493
}

0 commit comments

Comments
 (0)