diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/ide/highlight.rs | 12 | ||||
| -rw-r--r-- | src/syntax/parser.rs | 2 |
2 files changed, 9 insertions, 5 deletions
diff --git a/src/ide/highlight.rs b/src/ide/highlight.rs index 2e418e22..e00007f3 100644 --- a/src/ide/highlight.rs +++ b/src/ide/highlight.rs @@ -256,9 +256,13 @@ pub fn highlight(node: &LinkedNode) -> Option<Category> { /// Highlight an identifier based on context. fn highlight_ident(node: &LinkedNode) -> Option<Category> { // Are we directly before an argument list? - let next_leaf_kind = node.next_leaf().map(|leaf| leaf.kind()); - if matches!(next_leaf_kind, Some(SyntaxKind::LeftParen | SyntaxKind::LeftBracket)) { - return Some(Category::Function); + let next_leaf = node.next_leaf(); + if let Some(next) = &next_leaf { + if node.range().end == next.offset() + && matches!(next.kind(), SyntaxKind::LeftParen | SyntaxKind::LeftBracket) + { + return Some(Category::Function); + } } // Are we in math? @@ -273,7 +277,7 @@ fn highlight_ident(node: &LinkedNode) -> Option<Category> { } // Are we directly before a show rule colon? - if next_leaf_kind == Some(SyntaxKind::Colon) + if next_leaf.map(|leaf| leaf.kind()) == Some(SyntaxKind::Colon) && ancestor.parent_kind() == Some(SyntaxKind::ShowRule) { return Some(Category::Function); diff --git a/src/syntax/parser.rs b/src/syntax/parser.rs index b51de59e..1f9bdedd 100644 --- a/src/syntax/parser.rs +++ b/src/syntax/parser.rs @@ -507,7 +507,7 @@ fn embedded_code_expr(p: &mut Parser) { fn code_expr_prec(p: &mut Parser, atomic: bool, min_prec: usize) { let m = p.marker(); - if let Some(op) = ast::UnOp::from_kind(p.current()) { + if let (false, Some(op)) = (atomic, ast::UnOp::from_kind(p.current())) { p.eat(); code_expr_prec(p, atomic, op.precedence()); p.wrap(m, SyntaxKind::Unary); |
