From ee049b256a7718fb346a7172a34f0fc324b3269b Mon Sep 17 00:00:00 2001 From: ivan770 Date: Sat, 13 Feb 2021 15:47:53 +0200 Subject: Improve runnable annotations order, fix incorrect ignore detection --- crates/ide/src/annotations.rs | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) (limited to 'crates/ide/src/annotations.rs') diff --git a/crates/ide/src/annotations.rs b/crates/ide/src/annotations.rs index 97a361194..43250bf5d 100644 --- a/crates/ide/src/annotations.rs +++ b/crates/ide/src/annotations.rs @@ -50,25 +50,26 @@ pub(crate) fn annotations( if config.annotate_runnables { for runnable in runnables(db, file_id) { - if !matches!(runnable.kind, RunnableKind::Bin) || !config.binary_target { + if should_skip_runnable(&runnable.kind, config.binary_target) { continue; } let action = runnable.action(); let range = runnable.nav.full_range; - if config.run { + if action.debugee && config.debug { annotations.push(Annotation { range, + // FIXME: This one allocates without reason if run is enabled, but debug is disabled - kind: AnnotationKind::Runnable { debug: false, runnable: runnable.clone() }, + kind: AnnotationKind::Runnable { debug: true, runnable: runnable.clone() }, }); } - if action.debugee && config.debug { + if config.run { annotations.push(Annotation { range, - kind: AnnotationKind::Runnable { debug: true, runnable }, + kind: AnnotationKind::Runnable { debug: false, runnable }, }); } } @@ -144,6 +145,13 @@ pub(crate) fn resolve_annotation(db: &RootDatabase, mut annotation: Annotation) annotation } +fn should_skip_runnable(kind: &RunnableKind, binary_target: bool) -> bool { + match kind { + RunnableKind::Bin => !binary_target, + _ => false, + } +} + #[cfg(test)] mod tests { use ide_db::base_db::{FileId, FileRange}; -- cgit v1.2.3