From cda1a6c63860013ff43f34c68532db41abc30516 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Fri, 3 Jul 2020 23:46:36 +0200 Subject: Cleanup more completion tests --- crates/ra_ide/src/completion/complete_keyword.rs | 31 ++++++++++++++++++++++++ 1 file changed, 31 insertions(+) (limited to 'crates/ra_ide/src/completion/complete_keyword.rs') diff --git a/crates/ra_ide/src/completion/complete_keyword.rs b/crates/ra_ide/src/completion/complete_keyword.rs index 34d061f5a..086b917ce 100644 --- a/crates/ra_ide/src/completion/complete_keyword.rs +++ b/crates/ra_ide/src/completion/complete_keyword.rs @@ -1,6 +1,7 @@ //! FIXME: write short doc here use ra_syntax::{ast, SyntaxKind}; +use test_utils::mark; use crate::completion::{ CompletionContext, CompletionItem, CompletionItemKind, CompletionKind, Completions, @@ -38,6 +39,7 @@ pub(super) fn complete_use_tree_keyword(acc: &mut Completions, ctx: &CompletionC pub(super) fn complete_expr_keyword(acc: &mut Completions, ctx: &CompletionContext) { if ctx.token.kind() == SyntaxKind::COMMENT { + mark::hit!(no_keyword_completion_in_comments); return; } @@ -180,6 +182,7 @@ mod tests { test_utils::{check_edit, completion_list}, CompletionKind, }; + use test_utils::mark; fn check(ra_fixture: &str, expect: Expect) { let actual = completion_list(ra_fixture, CompletionKind::Keyword); @@ -459,4 +462,32 @@ fn quux() -> i32 { "#]], ); } + + #[test] + fn no_keyword_completion_in_comments() { + mark::check!(no_keyword_completion_in_comments); + check( + r#" +fn test() { + let x = 2; // A comment<|> +} +"#, + expect![[""]], + ); + check( + r#" +/* +Some multi-line comment<|> +*/ +"#, + expect![[""]], + ); + check( + r#" +/// Some doc comment +/// let test<|> = 1 +"#, + expect![[""]], + ); + } } -- cgit v1.2.3