From 77af7b087fd95140c28b30bf7127d7d83fb0dcc6 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Fri, 20 Dec 2019 14:11:49 +0100 Subject: Fix highlighting for field init shorthand --- crates/ra_ide/src/snapshots/highlighting.html | 2 +- crates/ra_ide/src/syntax_highlighting.rs | 7 +++---- 2 files changed, 4 insertions(+), 5 deletions(-) (limited to 'crates/ra_ide') diff --git a/crates/ra_ide/src/snapshots/highlighting.html b/crates/ra_ide/src/snapshots/highlighting.html index 748fd9558..a097cf8e8 100644 --- a/crates/ra_ide/src/snapshots/highlighting.html +++ b/crates/ra_ide/src/snapshots/highlighting.html @@ -41,7 +41,7 @@ pre { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padd let mut vec = Vec::new(); if true { let x = 92; - vec.push(Foo { x, y: 1 }); + vec.push(Foo { x, y: 1 }); } unsafe { vec.set_len(0); } diff --git a/crates/ra_ide/src/syntax_highlighting.rs b/crates/ra_ide/src/syntax_highlighting.rs index 63f5d3cb0..657c7b21a 100644 --- a/crates/ra_ide/src/syntax_highlighting.rs +++ b/crates/ra_ide/src/syntax_highlighting.rs @@ -102,11 +102,10 @@ pub(crate) fn highlight(db: &RootDatabase, file_id: FileId) -> Vec tags::LITERAL_COMMENT, STRING | RAW_STRING | RAW_BYTE_STRING | BYTE_STRING => tags::LITERAL_STRING, ATTR => tags::LITERAL_ATTRIBUTE, + // Special-case field init shorthand + NAME_REF if node.parent().and_then(ast::RecordField::cast).is_some() => tags::FIELD, + NAME_REF if node.ancestors().any(|it| it.kind() == ATTR) => continue, NAME_REF => { - if node.ancestors().any(|it| it.kind() == ATTR) { - continue; - } - let name_ref = node.as_node().cloned().and_then(ast::NameRef::cast).unwrap(); let name_kind = classify_name_ref(db, InFile::new(file_id.into(), &name_ref)).map(|d| d.kind); -- cgit v1.2.3