From c9af469b85854ec96318b96d7d1fde0935ee4e34 Mon Sep 17 00:00:00 2001 From: Lukas Wirth Date: Sun, 25 Oct 2020 23:05:30 +0100 Subject: Fix unary minus highlighting --- crates/ide/src/syntax_highlighting.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'crates/ide/src/syntax_highlighting.rs') diff --git a/crates/ide/src/syntax_highlighting.rs b/crates/ide/src/syntax_highlighting.rs index 750848467..9f864179e 100644 --- a/crates/ide/src/syntax_highlighting.rs +++ b/crates/ide/src/syntax_highlighting.rs @@ -579,7 +579,14 @@ fn highlight_element( } } T![-] if element.parent().and_then(ast::PrefixExpr::cast).is_some() => { - HighlightTag::NumericLiteral.into() + let prefix_expr = element.parent().and_then(ast::PrefixExpr::cast)?; + + let expr = prefix_expr.expr()?; + match expr { + ast::Expr::Literal(_) => HighlightTag::NumericLiteral, + _ => HighlightTag::Operator, + } + .into() } _ if element.parent().and_then(ast::PrefixExpr::cast).is_some() => { HighlightTag::Operator.into() -- cgit v1.2.3