From e09723f0afb3f86da046bd58026427e587d0ce10 Mon Sep 17 00:00:00 2001 From: Lukas Wirth Date: Fri, 11 Jun 2021 21:19:19 +0200 Subject: [PATCH] Highlight tuple field accesses correctly --- crates/ide/src/syntax_highlighting/highlight.rs | 3 +++ .../ide/src/syntax_highlighting/test_data/highlighting.html | 4 ++-- crates/ide/src/syntax_highlighting/tests.rs | 4 ++-- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/crates/ide/src/syntax_highlighting/highlight.rs b/crates/ide/src/syntax_highlighting/highlight.rs index 9503c936d1..84012227d8 100644 --- a/crates/ide/src/syntax_highlighting/highlight.rs +++ b/crates/ide/src/syntax_highlighting/highlight.rs @@ -131,6 +131,9 @@ pub(super) fn element( } STRING | BYTE_STRING => HlTag::StringLiteral.into(), ATTR => HlTag::Attribute.into(), + INT_NUMBER if element.ancestors().nth(1).map_or(false, |it| it.kind() == FIELD_EXPR) => { + SymbolKind::Field.into() + } INT_NUMBER | FLOAT_NUMBER => HlTag::NumericLiteral.into(), BYTE => HlTag::ByteLiteral.into(), CHAR => HlTag::CharLiteral.into(), diff --git a/crates/ide/src/syntax_highlighting/test_data/highlighting.html b/crates/ide/src/syntax_highlighting/test_data/highlighting.html index a7b5c3b895..59f1e8e4cc 100644 --- a/crates/ide/src/syntax_highlighting/test_data/highlighting.html +++ b/crates/ide/src/syntax_highlighting/test_data/highlighting.html @@ -215,8 +215,8 @@ pre { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padd let a = |x| x; let bar = Foo::baz; - let baz = -42; - let baz = -baz; + let baz = (-42,); + let baz = -baz.0; let _ = !true; diff --git a/crates/ide/src/syntax_highlighting/tests.rs b/crates/ide/src/syntax_highlighting/tests.rs index 6ad2a362a6..f7d8334a00 100644 --- a/crates/ide/src/syntax_highlighting/tests.rs +++ b/crates/ide/src/syntax_highlighting/tests.rs @@ -189,8 +189,8 @@ fn main() { let a = |x| x; let bar = Foo::baz; - let baz = -42; - let baz = -baz; + let baz = (-42,); + let baz = -baz.0; let _ = !true;