aboutsummaryrefslogtreecommitdiff
path: root/crates/ide/src/syntax_highlighting
diff options
context:
space:
mode:
authorLukas Wirth <[email protected]>2021-04-19 10:41:45 +0100
committerLukas Wirth <[email protected]>2021-04-19 10:41:45 +0100
commit8a959497b1fab35294d8ccfa5e51c80a3551a224 (patch)
tree81e8006553622c11e1299fbfa9ca98a5755099f4 /crates/ide/src/syntax_highlighting
parent75bf8328994e0966d381061647ac7dbbce374b39 (diff)
Don't require all doc fences to be valid for identifying rust code
Diffstat (limited to 'crates/ide/src/syntax_highlighting')
-rw-r--r--crates/ide/src/syntax_highlighting/inject.rs4
1 files changed, 3 insertions, 1 deletions
diff --git a/crates/ide/src/syntax_highlighting/inject.rs b/crates/ide/src/syntax_highlighting/inject.rs
index 855c7fba8..6b1037870 100644
--- a/crates/ide/src/syntax_highlighting/inject.rs
+++ b/crates/ide/src/syntax_highlighting/inject.rs
@@ -85,6 +85,8 @@ const RUSTDOC_FENCE_TOKENS: &[&'static str] = &[
85 "ignore", 85 "ignore",
86 "no_run", 86 "no_run",
87 "compile_fail", 87 "compile_fail",
88 "allow_fail",
89 "test_harness",
88 "edition2015", 90 "edition2015",
89 "edition2018", 91 "edition2018",
90 "edition2021", 92 "edition2021",
@@ -181,7 +183,7 @@ pub(super) fn doc_comment(
181 is_codeblock = !is_codeblock; 183 is_codeblock = !is_codeblock;
182 // Check whether code is rust by inspecting fence guards 184 // Check whether code is rust by inspecting fence guards
183 let guards = &line[idx + RUSTDOC_FENCE.len()..]; 185 let guards = &line[idx + RUSTDOC_FENCE.len()..];
184 let is_rust = guards.split(',').all(|sub| is_rustdoc_fence_token(sub.trim())); 186 let is_rust = guards.split(',').any(|sub| is_rustdoc_fence_token(sub.trim()));
185 is_doctest = is_codeblock && is_rust; 187 is_doctest = is_codeblock && is_rust;
186 continue; 188 continue;
187 } 189 }