From 54a3002b74bb464610dabf024f70d99058a634a8 Mon Sep 17 00:00:00 2001 From: Vishruth-Thimmaiah Date: Wed, 1 Jan 2025 21:50:06 +0530 Subject: [PATCH] fix: do not offer completions within macro strings --- crates/ide-completion/src/context/analysis.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/crates/ide-completion/src/context/analysis.rs b/crates/ide-completion/src/context/analysis.rs index 1c4cbb25b1fd..a96ba5d1f2f4 100644 --- a/crates/ide-completion/src/context/analysis.rs +++ b/crates/ide-completion/src/context/analysis.rs @@ -417,6 +417,14 @@ fn analyze( derive_ctx, } = expansion_result; + if original_token.kind() != self_token.kind() + && !(original_token.kind().is_punct() || original_token.kind().is_trivia()) + && !(SyntaxKind::is_any_identifier(original_token.kind()) + && SyntaxKind::is_any_identifier(self_token.kind())) + { + return None; + } + // Overwrite the path kind for derives if let Some((original_file, file_with_fake_ident, offset, origin_attr)) = derive_ctx { if let Some(ast::NameLike::NameRef(name_ref)) =