Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'crates/ide/src/annotations.rs')
| -rw-r--r-- | crates/ide/src/annotations.rs | 67 |
1 files changed, 36 insertions, 31 deletions
diff --git a/crates/ide/src/annotations.rs b/crates/ide/src/annotations.rs index 006e6e8246..e47891bbdf 100644 --- a/crates/ide/src/annotations.rs +++ b/crates/ide/src/annotations.rs @@ -1,6 +1,6 @@ use hir::{HasSource, InFile, InRealFile, Semantics}; use ide_db::{ - defs::Definition, helpers::visit_file_defs, FileId, FilePosition, FileRange, FxHashSet, + defs::Definition, helpers::visit_file_defs, FileId, FilePosition, FileRange, FxIndexSet, RootDatabase, }; use itertools::Itertools; @@ -55,7 +55,7 @@ pub(crate) fn annotations( config: &AnnotationConfig, file_id: FileId, ) -> Vec<Annotation> { - let mut annotations = FxHashSet::default(); + let mut annotations = FxIndexSet::default(); if config.annotate_runnables { for runnable in runnables(db, file_id) { @@ -170,7 +170,12 @@ pub(crate) fn annotations( })); } - annotations.into_iter().sorted_by_key(|a| (a.range.start(), a.range.end())).collect() + annotations + .into_iter() + .sorted_by_key(|a| { + (a.range.start(), a.range.end(), matches!(a.kind, AnnotationKind::Runnable(..))) + }) + .collect() } pub(crate) fn resolve_annotation(db: &RootDatabase, mut annotation: Annotation) -> Annotation { @@ -537,6 +542,20 @@ fn main() { }, Annotation { range: 69..73, + kind: HasReferences { + pos: FilePositionWrapper { + file_id: FileId( + 0, + ), + offset: 69, + }, + data: Some( + [], + ), + }, + }, + Annotation { + range: 69..73, kind: Runnable( Runnable { use_name_in_title: false, @@ -559,20 +578,6 @@ fn main() { }, ), }, - Annotation { - range: 69..73, - kind: HasReferences { - pos: FilePositionWrapper { - file_id: FileId( - 0, - ), - offset: 69, - }, - data: Some( - [], - ), - }, - }, ] "#]], ); @@ -719,6 +724,20 @@ fn main() { }, Annotation { range: 61..65, + kind: HasReferences { + pos: FilePositionWrapper { + file_id: FileId( + 0, + ), + offset: 61, + }, + data: Some( + [], + ), + }, + }, + Annotation { + range: 61..65, kind: Runnable( Runnable { use_name_in_title: false, @@ -741,20 +760,6 @@ fn main() { }, ), }, - Annotation { - range: 61..65, - kind: HasReferences { - pos: FilePositionWrapper { - file_id: FileId( - 0, - ), - offset: 61, - }, - data: Some( - [], - ), - }, - }, ] "#]], ); |