diff options
Diffstat (limited to 'crates')
-rw-r--r-- | crates/ide/src/annotations.rs | 18 |
1 files changed, 13 insertions, 5 deletions
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( | |||
50 | 50 | ||
51 | if config.annotate_runnables { | 51 | if config.annotate_runnables { |
52 | for runnable in runnables(db, file_id) { | 52 | for runnable in runnables(db, file_id) { |
53 | if !matches!(runnable.kind, RunnableKind::Bin) || !config.binary_target { | 53 | if should_skip_runnable(&runnable.kind, config.binary_target) { |
54 | continue; | 54 | continue; |
55 | } | 55 | } |
56 | 56 | ||
57 | let action = runnable.action(); | 57 | let action = runnable.action(); |
58 | let range = runnable.nav.full_range; | 58 | let range = runnable.nav.full_range; |
59 | 59 | ||
60 | if config.run { | 60 | if action.debugee && config.debug { |
61 | annotations.push(Annotation { | 61 | annotations.push(Annotation { |
62 | range, | 62 | range, |
63 | |||
63 | // FIXME: This one allocates without reason if run is enabled, but debug is disabled | 64 | // FIXME: This one allocates without reason if run is enabled, but debug is disabled |
64 | kind: AnnotationKind::Runnable { debug: false, runnable: runnable.clone() }, | 65 | kind: AnnotationKind::Runnable { debug: true, runnable: runnable.clone() }, |
65 | }); | 66 | }); |
66 | } | 67 | } |
67 | 68 | ||
68 | if action.debugee && config.debug { | 69 | if config.run { |
69 | annotations.push(Annotation { | 70 | annotations.push(Annotation { |
70 | range, | 71 | range, |
71 | kind: AnnotationKind::Runnable { debug: true, runnable }, | 72 | kind: AnnotationKind::Runnable { debug: false, runnable }, |
72 | }); | 73 | }); |
73 | } | 74 | } |
74 | } | 75 | } |
@@ -144,6 +145,13 @@ pub(crate) fn resolve_annotation(db: &RootDatabase, mut annotation: Annotation) | |||
144 | annotation | 145 | annotation |
145 | } | 146 | } |
146 | 147 | ||
148 | fn should_skip_runnable(kind: &RunnableKind, binary_target: bool) -> bool { | ||
149 | match kind { | ||
150 | RunnableKind::Bin => !binary_target, | ||
151 | _ => false, | ||
152 | } | ||
153 | } | ||
154 | |||
147 | #[cfg(test)] | 155 | #[cfg(test)] |
148 | mod tests { | 156 | mod tests { |
149 | use ide_db::base_db::{FileId, FileRange}; | 157 | use ide_db::base_db::{FileId, FileRange}; |