aboutsummaryrefslogtreecommitdiff
path: root/helix-term
diff options
context:
space:
mode:
authorBlaž Hrastnik2021-11-07 12:26:03 +0000
committerBlaž Hrastnik2021-11-07 12:26:03 +0000
commit65868081fcc54aa4ce2ede3b95bb9800534f41f8 (patch)
tree3f1527268c73430eec45bcb4d5ee44354a5d1474 /helix-term
parent4f2a01cc092d184fd0f841c6cfc237e1101521b4 (diff)
dap: Simplify launch & start
There's no need to re-detect language config, just use the one available on the document.
Diffstat (limited to 'helix-term')
-rw-r--r--helix-term/src/commands/dap.rs37
1 files changed, 11 insertions, 26 deletions
diff --git a/helix-term/src/commands/dap.rs b/helix-term/src/commands/dap.rs
index 0229b453..d9f0ba8f 100644
--- a/helix-term/src/commands/dap.rs
+++ b/helix-term/src/commands/dap.rs
@@ -165,19 +165,10 @@ pub fn dap_start_impl(
socket: Option<std::net::SocketAddr>,
params: Option<Vec<&str>>,
) {
- let (_, doc) = current!(editor);
+ let doc = doc!(editor);
- let path = match doc.path() {
- Some(path) => path,
- None => {
- editor.set_error("Can't start debug: document has no path".to_string());
- return;
- }
- };
-
- let language_config = editor.syn_loader.language_config_for_file_name(path);
- let config = match language_config
- .as_deref()
+ let config = match doc
+ .language_config()
.and_then(|config| config.debugger.as_ref())
{
Some(c) => c,
@@ -283,7 +274,8 @@ pub fn dap_start_impl(
}
};
if let Err(e) = result {
- editor.set_error(format!("Failed {} target: {}", start_config.request, e));
+ let msg = format!("Failed {} target: {}", start_config.request, e);
+ editor.set_error(msg);
return;
}
@@ -300,19 +292,10 @@ pub fn dap_launch(cx: &mut Context) {
return;
}
- let (_, doc) = current!(cx.editor);
- let path = match doc.path() {
- Some(path) => path,
- None => {
- cx.editor
- .set_error("Can't start debug: document has no path".to_string());
- return;
- }
- };
+ let doc = doc!(cx.editor);
- let language_config = cx.editor.syn_loader.language_config_for_file_name(path);
- let config = match language_config
- .as_deref()
+ let config = match doc
+ .language_config()
.and_then(|config| config.debugger.as_ref())
{
Some(c) => c,
@@ -324,9 +307,11 @@ pub fn dap_launch(cx: &mut Context) {
}
};
+ let templates = config.templates.clone();
+
cx.push_layer(Box::new(Picker::new(
true,
- config.templates.clone(),
+ templates,
|template| template.name.as_str().into(),
|cx, template, _action| {
let completions = template.completion.clone();