mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-30 13:51:31 +00:00
Fix incorrect order of syntax highlight ranges
This commit is contained in:
parent
8a4cebafca
commit
2e2c03ee2d
2 changed files with 14 additions and 1 deletions
|
@ -174,7 +174,8 @@ pub(crate) fn highlight(
|
||||||
}
|
}
|
||||||
|
|
||||||
assert_eq!(res.len(), 1, "after DFS traversal, the stack should only contain a single element");
|
assert_eq!(res.len(), 1, "after DFS traversal, the stack should only contain a single element");
|
||||||
let res = res.pop().unwrap();
|
let mut res = res.pop().unwrap();
|
||||||
|
res.sort_by_key(|range| range.range.start());
|
||||||
// Check that ranges are sorted and disjoint
|
// Check that ranges are sorted and disjoint
|
||||||
assert!(res
|
assert!(res
|
||||||
.iter()
|
.iter()
|
||||||
|
|
|
@ -156,3 +156,15 @@ fn main() {
|
||||||
fs::write(dst_file, &actual_html).unwrap();
|
fs::write(dst_file, &actual_html).unwrap();
|
||||||
assert_eq_text!(expected_html, actual_html);
|
assert_eq_text!(expected_html, actual_html);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn ranges_sorted() {
|
||||||
|
let (analysis, file_id) = single_file(
|
||||||
|
r#"
|
||||||
|
#[foo(bar = "bar")]
|
||||||
|
macro_rules! test {}
|
||||||
|
}"#
|
||||||
|
.trim(),
|
||||||
|
);
|
||||||
|
let _ = analysis.highlight(file_id).unwrap();
|
||||||
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue