Skip to content

Commit 91cb422

Browse files
bors[bot]Veykril
andauthored
Merge #10859
10859: fix: Prioritize tuple fields in highlight_related r=Veykril a=Veykril bors r+ Co-authored-by: Lukas Wirth <[email protected]>
2 parents 870e730 + 4bf75c5 commit 91cb422

File tree

1 file changed

+18
-3
lines changed

1 file changed

+18
-3
lines changed

crates/ide/src/highlight_related.rs

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use rustc_hash::FxHashSet;
1010
use syntax::{
1111
ast::{self, HasLoopBody},
1212
match_ast, AstNode,
13-
SyntaxKind::IDENT,
13+
SyntaxKind::{IDENT, INT_NUMBER},
1414
SyntaxNode, SyntaxToken, TextRange, T,
1515
};
1616

@@ -54,10 +54,9 @@ pub(crate) fn highlight_related(
5454
T![?] => 4, // prefer `?` when the cursor is sandwiched like in `await$0?`
5555
T![->] => 3,
5656
kind if kind.is_keyword() => 2,
57-
IDENT => 1,
57+
IDENT | INT_NUMBER => 1,
5858
_ => 0,
5959
})?;
60-
6160
match token.kind() {
6261
T![?] if config.exit_points && token.parent().and_then(ast::TryExpr::cast).is_some() => {
6362
highlight_exit_points(sema, token)
@@ -346,6 +345,22 @@ mod tests {
346345
assert_eq!(expected, actual);
347346
}
348347

348+
#[test]
349+
fn test_hl_tuple_fields() {
350+
check(
351+
r#"
352+
struct Tuple(u32, u32);
353+
354+
fn foo(t: Tuple) {
355+
t.0$0;
356+
// ^ read
357+
t.0;
358+
// ^ read
359+
}
360+
"#,
361+
);
362+
}
363+
349364
#[test]
350365
fn test_hl_module() {
351366
check(

0 commit comments

Comments
 (0)