about summary refs log tree commit diff
diff options
context:
space:
mode:
authorJake Heinz <jh@discordapp.com>2022-01-03 01:50:49 +0000
committerJake Heinz <jh@discordapp.com>2022-01-03 01:53:58 +0000
commit04decd5e6b36574ca30369c26481d5a51d739971 (patch)
tree1320bd27883a39e7556e75c3813f0a2d2580e025
parentdf3d3d8a74e9c4780cec9f6a2bd687406dade8af (diff)
downloadrust-04decd5e6b36574ca30369c26481d5a51d739971.tar.gz
rust-04decd5e6b36574ca30369c26481d5a51d739971.zip
internal: dont descend into comments
-rw-r--r--crates/ide/src/syntax_highlighting.rs5
1 files changed, 4 insertions, 1 deletions
diff --git a/crates/ide/src/syntax_highlighting.rs b/crates/ide/src/syntax_highlighting.rs
index 28c7c546fff..f20d629fbf1 100644
--- a/crates/ide/src/syntax_highlighting.rs
+++ b/crates/ide/src/syntax_highlighting.rs
@@ -282,7 +282,10 @@ fn traverse(
 
         // only attempt to descend if we are inside a macro call or attribute
         // as calling `descend_into_macros_single` gets rather expensive if done for every single token
-        let descend_token = current_macro_call.is_some() || current_attr_call.is_some();
+        // additionally, do not descend into comments, descending maps down to doc attributes which get
+        // tagged as string literals.
+        let descend_token = (current_macro_call.is_some() || current_attr_call.is_some())
+            && element.kind() != COMMENT;
         let element_to_highlight = if descend_token {
             let token = match &element {
                 NodeOrToken::Node(_) => continue,