Fix unary minus highlighting

This commit is contained in:
Lukas Wirth 2020-10-25 23:05:30 +01:00
parent 91c1af3612
commit c9af469b85
3 changed files with 14 additions and 1 deletions

View file

@ -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()