mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-01 11:31:15 +00:00
feat: highlight tail expression in labeled block
This commit is contained in:
parent
c5882732e6
commit
78503f2d1f
@ -446,6 +446,18 @@ pub(crate) fn highlight_break_points(
|
||||
push_to_highlights(file_id, text_range);
|
||||
});
|
||||
|
||||
if matches!(expr, ast::Expr::BlockExpr(_)) {
|
||||
for_each_tail_expr(&expr, &mut |tail| {
|
||||
if matches!(tail, ast::Expr::BreakExpr(_)) {
|
||||
return;
|
||||
}
|
||||
|
||||
let file_id = sema.hir_file_for(tail.syntax());
|
||||
let range = tail.syntax().text_range();
|
||||
push_to_highlights(file_id, Some(range));
|
||||
});
|
||||
}
|
||||
|
||||
Some(highlights)
|
||||
}
|
||||
|
||||
@ -2072,4 +2084,21 @@ pub unsafe fn bootstrap() -> ! {
|
||||
"#,
|
||||
)
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn labeled_block_tail_expr() {
|
||||
check(
|
||||
r#"
|
||||
fn foo() {
|
||||
'a: {
|
||||
// ^^^
|
||||
if true { break$0 'a 0; }
|
||||
// ^^^^^^^^
|
||||
5
|
||||
// ^
|
||||
}
|
||||
}
|
||||
"#,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user