dap: Minor simplifications

pull/574/head
Blaž Hrastnik 3 years ago
parent 65868081fc
commit 9963a5614d

@ -123,7 +123,8 @@ fn thread_picker(cx: &mut Context, callback_fn: impl Fn(&mut Editor, &dap::Threa
thread.name, thread.name,
thread_states thread_states
.get(&thread.id) .get(&thread.id)
.unwrap_or(&"unknown".to_owned()) .map(|state| state.as_str())
.unwrap_or("unknown")
) )
.into() .into()
}, },
@ -173,9 +174,7 @@ pub fn dap_start_impl(
{ {
Some(c) => c, Some(c) => c,
None => { None => {
editor.set_error( editor.set_error("No debug adapter available for language".to_string());
"Can't start debug: no debug adapter available for language".to_string(),
);
return; return;
} }
}; };
@ -215,7 +214,7 @@ pub fn dap_start_impl(
let start_config = match start_config { let start_config = match start_config {
Some(c) => c, Some(c) => c,
None => { None => {
editor.set_error("Can't start debug: no debug config with given name".to_string()); editor.set_error("No debug config with given name".to_string());
return; return;
} }
}; };
@ -288,7 +287,7 @@ pub fn dap_start_impl(
pub fn dap_launch(cx: &mut Context) { pub fn dap_launch(cx: &mut Context) {
if cx.editor.debugger.is_some() { if cx.editor.debugger.is_some() {
cx.editor cx.editor
.set_error("Can't start debug: debugger is running".to_string()); .set_error("Debugger is already running".to_string());
return; return;
} }
@ -300,9 +299,8 @@ pub fn dap_launch(cx: &mut Context) {
{ {
Some(c) => c, Some(c) => c,
None => { None => {
cx.editor.set_error( cx.editor
"Can't start debug: no debug adapter available for language".to_string(), .set_error("No debug adapter available for language".to_string());
);
return; return;
} }
}; };
@ -658,7 +656,7 @@ pub fn dap_edit_condition(cx: &mut Context) {
return; return;
} }
let (_, doc) = current!(cx.editor); let doc = doc!(cx.editor);
let path = match doc.path() { let path = match doc.path() {
Some(path) => path, Some(path) => path,
None => { None => {
@ -737,7 +735,7 @@ pub fn dap_edit_log(cx: &mut Context) {
return; return;
} }
let (_, doc) = current!(cx.editor); let doc = doc!(cx.editor);
let path = match doc.path() { let path = match doc.path() {
Some(path) => path, Some(path) => path,
None => { None => {

Loading…
Cancel
Save