Fix highlighting bugs

This commit is contained in:
Laurenz 2022-07-15 15:19:04 +02:00
parent 4817c62dfb
commit cbfac6cd45
2 changed files with 9 additions and 8 deletions

View File

@ -1067,7 +1067,7 @@ impl ShowExpr {
} }
node! { node! {
/// A wrap expression: wrap body in columns(2, body)`. /// A wrap expression: `wrap body in columns(2, body)`.
WrapExpr WrapExpr
} }

View File

@ -119,11 +119,11 @@ pub fn highlight_pre(text: &str, mode: TokenMode, theme: &Theme) -> String {
} }
if style.font_style.contains(FontStyle::BOLD) { if style.font_style.contains(FontStyle::BOLD) {
buf.push_str("font-weight:bold"); buf.push_str("font-weight:bold;");
} }
if style.font_style.contains(FontStyle::ITALIC) { if style.font_style.contains(FontStyle::ITALIC) {
buf.push_str("font-style:italic"); buf.push_str("font-style:italic;");
} }
if style.font_style.contains(FontStyle::UNDERLINE) { if style.font_style.contains(FontStyle::UNDERLINE) {
@ -209,6 +209,7 @@ impl Category {
NodeKind::Comma => Some(Category::Punctuation), NodeKind::Comma => Some(Category::Punctuation),
NodeKind::Semicolon => Some(Category::Punctuation), NodeKind::Semicolon => Some(Category::Punctuation),
NodeKind::Colon => Some(Category::Punctuation), NodeKind::Colon => Some(Category::Punctuation),
NodeKind::Dot => Some(Category::Punctuation),
NodeKind::LineComment => Some(Category::Comment), NodeKind::LineComment => Some(Category::Comment),
NodeKind::BlockComment => Some(Category::Comment), NodeKind::BlockComment => Some(Category::Comment),
NodeKind::Strong => Some(Category::Strong), NodeKind::Strong => Some(Category::Strong),
@ -253,7 +254,6 @@ impl Category {
_ => Some(Category::Operator), _ => Some(Category::Operator),
}, },
NodeKind::Slash => Some(Category::Operator), NodeKind::Slash => Some(Category::Operator),
NodeKind::Dot => Some(Category::Operator),
NodeKind::PlusEq => Some(Category::Operator), NodeKind::PlusEq => Some(Category::Operator),
NodeKind::HyphEq => Some(Category::Operator), NodeKind::HyphEq => Some(Category::Operator),
NodeKind::StarEq => Some(Category::Operator), NodeKind::StarEq => Some(Category::Operator),
@ -281,10 +281,11 @@ impl Category {
NodeKind::ShowExpr NodeKind::ShowExpr
if parent if parent
.children() .children()
.filter(|c| matches!(c.kind(), NodeKind::Ident(_))) .rev()
.map(SyntaxNode::span) .skip_while(|child| child.kind() != &NodeKind::As)
.nth(1) .take_while(|child| child.kind() != &NodeKind::Colon)
.map_or(false, |span| span == child.span()) => .find(|c| matches!(c.kind(), NodeKind::Ident(_)))
.map_or(false, |ident| std::ptr::eq(ident, child)) =>
{ {
Some(Category::Function) Some(Category::Function)
} }