From 3f1c73633eb3e5d8a2df3a72dc772087cfb18be4 Mon Sep 17 00:00:00 2001 From: George Fraser Date: Sun, 10 May 2020 11:08:32 -0700 Subject: Color `in` as a control keyword --- crates/ra_ide/src/syntax_highlighting.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'crates/ra_ide/src/syntax_highlighting.rs') diff --git a/crates/ra_ide/src/syntax_highlighting.rs b/crates/ra_ide/src/syntax_highlighting.rs index d53a39f57..16123c5cb 100644 --- a/crates/ra_ide/src/syntax_highlighting.rs +++ b/crates/ra_ide/src/syntax_highlighting.rs @@ -408,7 +408,8 @@ fn highlight_element( | T![loop] | T![match] | T![return] - | T![while] => h | HighlightModifier::ControlFlow, + | T![while] + | T![in] => h | HighlightModifier::ControlFlow, T![unsafe] => h | HighlightModifier::Unsafe, _ => h, } -- cgit v1.2.3 From 63b75a40c8c9e1f24fbd21c423f62f303281b77c Mon Sep 17 00:00:00 2001 From: George Fraser Date: Sun, 10 May 2020 11:26:19 -0700 Subject: Color `for` as a regular keyword when it's part of impl _ for _ --- crates/ra_ide/src/syntax_highlighting.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'crates/ra_ide/src/syntax_highlighting.rs') diff --git a/crates/ra_ide/src/syntax_highlighting.rs b/crates/ra_ide/src/syntax_highlighting.rs index 16123c5cb..be57eeb0a 100644 --- a/crates/ra_ide/src/syntax_highlighting.rs +++ b/crates/ra_ide/src/syntax_highlighting.rs @@ -403,13 +403,13 @@ fn highlight_element( T![break] | T![continue] | T![else] - | T![for] | T![if] | T![loop] | T![match] | T![return] | T![while] | T![in] => h | HighlightModifier::ControlFlow, + T![for] if !is_child_of_impl(element) => h | HighlightModifier::ControlFlow, T![unsafe] => h | HighlightModifier::Unsafe, _ => h, } @@ -433,6 +433,13 @@ fn highlight_element( } } +fn is_child_of_impl(element: SyntaxElement) -> bool { + match element.parent() { + Some(e) => e.kind() == IMPL_DEF, + _ => false, + } +} + fn highlight_name(db: &RootDatabase, def: Definition) -> Highlight { match def { Definition::Macro(_) => HighlightTag::Macro, -- cgit v1.2.3