Let the client care about presentation

This commit is contained in:
Aleksey Kladov 2021-07-11 13:42:19 +03:00
parent 148e11aa9e
commit 0dc186f612
2 changed files with 20 additions and 20 deletions

View File

@ -59,20 +59,10 @@ pub(crate) fn annotations(
let range = runnable.nav.focus_or_full_range();
// dbg_runnable should go after the run annotation, to prevent a clone we do it this way
let dbg_runnable = (runnable.debugee() && config.debug).then(|| Annotation {
annotations.push(Annotation {
range,
kind: AnnotationKind::Runnable { debug: true, runnable: runnable.clone() },
kind: AnnotationKind::Runnable { debug: false, runnable },
});
if config.run {
annotations.push(Annotation {
range,
kind: AnnotationKind::Runnable { debug: false, runnable },
});
}
annotations.extend(dbg_runnable);
}
}

View File

@ -998,16 +998,26 @@ pub(crate) fn code_lens(
let annotation_range = range(&line_index, annotation.range);
let title = run.title();
let can_debug = run.debugee();
let r = runnable(snap, run)?;
let command =
if debug { command::debug_single(&r) } else { command::run_single(&r, &title) };
acc.push(lsp_types::CodeLens {
range: annotation_range,
command: Some(command),
data: None,
})
let lens_config = snap.config.lens();
if lens_config.run {
let command = command::run_single(&r, &title);
acc.push(lsp_types::CodeLens {
range: annotation_range,
command: Some(command),
data: None,
})
}
if lens_config.debug && can_debug {
let command = command::debug_single(&r);
acc.push(lsp_types::CodeLens {
range: annotation_range,
command: Some(command),
data: None,
})
}
}
AnnotationKind::HasImpls { position: file_position, data } => {
let line_index = snap.file_line_index(file_position.file_id)?;