summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLaurenz <laurmaedje@gmail.com>2022-07-15 15:19:04 +0200
committerLaurenz <laurmaedje@gmail.com>2022-07-26 20:32:50 +0200
commitcbfac6cd457d9a3c828d9f0e166444baac9dbb77 (patch)
tree3b45a0b661758ca177f4de37feb88c3282875b8a
parent4817c62dfbaf8cd200ed3582665995fd01fac263 (diff)
Fix highlighting bugs
-rw-r--r--src/syntax/ast.rs2
-rw-r--r--src/syntax/highlight.rs15
2 files changed, 9 insertions, 8 deletions
diff --git a/src/syntax/ast.rs b/src/syntax/ast.rs
index b90ecdff..67f9e038 100644
--- a/src/syntax/ast.rs
+++ b/src/syntax/ast.rs
@@ -1067,7 +1067,7 @@ impl ShowExpr {
}
node! {
- /// A wrap expression: wrap body in columns(2, body)`.
+ /// A wrap expression: `wrap body in columns(2, body)`.
WrapExpr
}
diff --git a/src/syntax/highlight.rs b/src/syntax/highlight.rs
index f6256d2a..b52234d4 100644
--- a/src/syntax/highlight.rs
+++ b/src/syntax/highlight.rs
@@ -119,11 +119,11 @@ pub fn highlight_pre(text: &str, mode: TokenMode, theme: &Theme) -> String {
}
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) {
- buf.push_str("font-style:italic");
+ buf.push_str("font-style:italic;");
}
if style.font_style.contains(FontStyle::UNDERLINE) {
@@ -209,6 +209,7 @@ impl Category {
NodeKind::Comma => Some(Category::Punctuation),
NodeKind::Semicolon => Some(Category::Punctuation),
NodeKind::Colon => Some(Category::Punctuation),
+ NodeKind::Dot => Some(Category::Punctuation),
NodeKind::LineComment => Some(Category::Comment),
NodeKind::BlockComment => Some(Category::Comment),
NodeKind::Strong => Some(Category::Strong),
@@ -253,7 +254,6 @@ impl Category {
_ => Some(Category::Operator),
},
NodeKind::Slash => Some(Category::Operator),
- NodeKind::Dot => Some(Category::Operator),
NodeKind::PlusEq => Some(Category::Operator),
NodeKind::HyphEq => Some(Category::Operator),
NodeKind::StarEq => Some(Category::Operator),
@@ -281,10 +281,11 @@ impl Category {
NodeKind::ShowExpr
if parent
.children()
- .filter(|c| matches!(c.kind(), NodeKind::Ident(_)))
- .map(SyntaxNode::span)
- .nth(1)
- .map_or(false, |span| span == child.span()) =>
+ .rev()
+ .skip_while(|child| child.kind() != &NodeKind::As)
+ .take_while(|child| child.kind() != &NodeKind::Colon)
+ .find(|c| matches!(c.kind(), NodeKind::Ident(_)))
+ .map_or(false, |ident| std::ptr::eq(ident, child)) =>
{
Some(Category::Function)
}