diff --git a/crates/ra_ide/src/snapshots/highlight_doctest.html b/crates/ra_ide/src/snapshots/highlight_doctest.html
index f1e007b09b..106c93077c 100644
--- a/crates/ra_ide/src/snapshots/highlight_doctest.html
+++ b/crates/ra_ide/src/snapshots/highlight_doctest.html
@@ -43,8 +43,8 @@ pre { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padd
- #![allow(unused_mut)]
- let mut foo: Foo = Foo::new();
+ #![allow(unused_mut)]
+ let mut foo: Foo = Foo::new();
pub const fn new() -> Foo {
Foo { bar: true }
@@ -55,26 +55,26 @@ pre { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padd
- use x::y;
+ use x::y;
- let foo = Foo::new();
+ let foo = Foo::new();
-
- assert!(foo.bar());
+
+ assert!(foo.bar());
- let bar = foo.bar || Foo::bar;
+ let bar = foo.bar || Foo::bar;
-
+
- let multi_line_string = "Foo
- bar
- ";
+ let multi_line_string = "Foo
+ bar
+ ";
- let foobar = Foo::new().bar();
+ let foobar = Foo::new().bar();
diff --git a/crates/ra_ide/src/syntax_highlighting.rs b/crates/ra_ide/src/syntax_highlighting.rs
index 68dff45b7f..6c43c5d941 100644
--- a/crates/ra_ide/src/syntax_highlighting.rs
+++ b/crates/ra_ide/src/syntax_highlighting.rs
@@ -477,10 +477,10 @@ fn highlight_element(
// Simple token-based highlighting
COMMENT => {
let comment = element.into_token().and_then(ast::Comment::cast)?;
- if comment.kind().doc.is_some() {
- Highlight::from(HighlightTag::Comment) | HighlightModifier::Documentation
- } else {
- HighlightTag::Comment.into()
+ let h = HighlightTag::Comment;
+ match comment.kind().doc {
+ Some(_) => h | HighlightModifier::Documentation,
+ None => h.into(),
}
}
STRING | RAW_STRING | RAW_BYTE_STRING | BYTE_STRING => HighlightTag::StringLiteral.into(),
diff --git a/crates/ra_ide/src/syntax_highlighting/injection.rs b/crates/ra_ide/src/syntax_highlighting/injection.rs
index 40436c5a22..dc12c8f5ae 100644
--- a/crates/ra_ide/src/syntax_highlighting/injection.rs
+++ b/crates/ra_ide/src/syntax_highlighting/injection.rs
@@ -8,8 +8,8 @@ use ra_syntax::{ast, AstToken, SyntaxNode, SyntaxToken, TextRange, TextSize};
use stdx::SepBy;
use crate::{
- call_info::ActiveParameter, Analysis, Highlight, HighlightModifier, HighlightTag,
- HighlightedRange, RootDatabase,
+ call_info::ActiveParameter, Analysis, HighlightModifier, HighlightTag, HighlightedRange,
+ RootDatabase,
};
use super::HighlightedRangeStack;
@@ -121,8 +121,7 @@ pub(super) fn extract_doc_comments(
range.start(),
range.start() + TextSize::try_from(pos).unwrap(),
),
- highlight: Highlight::from(HighlightTag::Comment)
- | HighlightModifier::Documentation,
+ highlight: HighlightTag::Comment | HighlightModifier::Documentation,
binding_hash: None,
});
line_start += range.len() - TextSize::try_from(pos).unwrap();
@@ -168,6 +167,8 @@ pub(super) fn highlight_doc_comment(
h.range.start() + start_offset,
h.range.end() + end_offset.unwrap_or(start_offset),
);
+
+ h.highlight |= HighlightModifier::Documentation;
stack.add(h);
}
}