From 04076bc5fbd1013568438e3b7b7ad20e20672060 Mon Sep 17 00:00:00 2001 From: Lukas Wirth Date: Wed, 18 Aug 2021 15:02:31 +0200 Subject: [PATCH] Don't trigger related highlighting on unrelated tokens --- crates/ide/src/highlight_related.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/crates/ide/src/highlight_related.rs b/crates/ide/src/highlight_related.rs index 6fba65660bc3..bd0d261ba999 100644 --- a/crates/ide/src/highlight_related.rs +++ b/crates/ide/src/highlight_related.rs @@ -51,13 +51,15 @@ pub(crate) fn highlight_related( })?; match token.kind() { - T![fn] | T![return] | T![?] | T![->] if config.exit_points => { + T![?] if config.exit_points && token.parent().and_then(ast::TryExpr::cast).is_some() => { highlight_exit_points(sema, token) } + T![fn] | T![return] | T![->] if config.exit_points => highlight_exit_points(sema, token), T![await] | T![async] if config.yield_points => highlight_yield_points(token), - T![break] | T![loop] | T![for] | T![while] if config.break_points => { + T![for] if config.break_points && token.parent().and_then(ast::ForExpr::cast).is_some() => { highlight_break_points(token) } + T![break] | T![loop] | T![while] if config.break_points => highlight_break_points(token), _ if config.references => highlight_references(sema, &syntax, position), _ => None, }