Skip to content

Commit 0dc186f

Browse files
committed
Let the client care about presentation
1 parent 148e11a commit 0dc186f

File tree

2 files changed

+20
-20
lines changed

2 files changed

+20
-20
lines changed

crates/ide/src/annotations.rs

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -59,20 +59,10 @@ pub(crate) fn annotations(
5959

6060
let range = runnable.nav.focus_or_full_range();
6161

62-
// dbg_runnable should go after the run annotation, to prevent a clone we do it this way
63-
let dbg_runnable = (runnable.debugee() && config.debug).then(|| Annotation {
62+
annotations.push(Annotation {
6463
range,
65-
kind: AnnotationKind::Runnable { debug: true, runnable: runnable.clone() },
64+
kind: AnnotationKind::Runnable { debug: false, runnable },
6665
});
67-
68-
if config.run {
69-
annotations.push(Annotation {
70-
range,
71-
kind: AnnotationKind::Runnable { debug: false, runnable },
72-
});
73-
}
74-
75-
annotations.extend(dbg_runnable);
7666
}
7767
}
7868

crates/rust-analyzer/src/to_proto.rs

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -998,16 +998,26 @@ pub(crate) fn code_lens(
998998
let annotation_range = range(&line_index, annotation.range);
999999

10001000
let title = run.title();
1001+
let can_debug = run.debugee();
10011002
let r = runnable(snap, run)?;
10021003

1003-
let command =
1004-
if debug { command::debug_single(&r) } else { command::run_single(&r, &title) };
1005-
1006-
acc.push(lsp_types::CodeLens {
1007-
range: annotation_range,
1008-
command: Some(command),
1009-
data: None,
1010-
})
1004+
let lens_config = snap.config.lens();
1005+
if lens_config.run {
1006+
let command = command::run_single(&r, &title);
1007+
acc.push(lsp_types::CodeLens {
1008+
range: annotation_range,
1009+
command: Some(command),
1010+
data: None,
1011+
})
1012+
}
1013+
if lens_config.debug && can_debug {
1014+
let command = command::debug_single(&r);
1015+
acc.push(lsp_types::CodeLens {
1016+
range: annotation_range,
1017+
command: Some(command),
1018+
data: None,
1019+
})
1020+
}
10111021
}
10121022
AnnotationKind::HasImpls { position: file_position, data } => {
10131023
let line_index = snap.file_line_index(file_position.file_id)?;

0 commit comments

Comments
 (0)