aboutsummaryrefslogtreecommitdiff
path: root/helix-term/src
diff options
context:
space:
mode:
authorBlaž Hrastnik2021-11-07 09:37:42 +0000
committerBlaž Hrastnik2021-11-07 09:38:04 +0000
commit9baddc825d57e09e635b653b2c171e104f85c552 (patch)
tree58ce5c257db1a0216bda5fbd4119c4f152cbf372 /helix-term/src
parentfd9b826f2c124ce1983191dd632f3e9ca37ba74c (diff)
dap: Get rid of excessive cloning
Diffstat (limited to 'helix-term/src')
-rw-r--r--helix-term/src/commands/dap.rs35
1 files changed, 17 insertions, 18 deletions
diff --git a/helix-term/src/commands/dap.rs b/helix-term/src/commands/dap.rs
index 7d438a30..d46e38eb 100644
--- a/helix-term/src/commands/dap.rs
+++ b/helix-term/src/commands/dap.rs
@@ -170,11 +170,11 @@ pub fn dap_start_impl(
}
};
- let config = editor
- .syn_loader
- .language_config_for_file_name(&path)
- .and_then(|x| x.debugger.clone());
- let config = match config {
+ let language_config = editor.syn_loader.language_config_for_file_name(&path);
+ let config = match language_config
+ .as_deref()
+ .and_then(|config| config.debugger.as_ref())
+ {
Some(c) => c,
None => {
editor.set_error(
@@ -187,10 +187,10 @@ pub fn dap_start_impl(
let result = match socket {
Some(socket) => block_on(Client::tcp(socket, 0)),
None => block_on(Client::process(
- config.transport.clone(),
- config.command.clone(),
- config.args.clone(),
- config.port_arg.clone(),
+ &config.transport,
+ &config.command,
+ config.args.iter().map(|arg| arg.as_str()).collect(),
+ config.port_arg.as_deref(),
0,
)),
};
@@ -209,7 +209,7 @@ pub fn dap_start_impl(
return;
}
- debugger.quirks = config.quirks;
+ debugger.quirks = config.quirks.clone();
let start_config = match name {
Some(name) => config.templates.iter().find(|t| t.name == name),
@@ -296,7 +296,7 @@ pub fn dap_launch(cx: &mut Context) {
let (_, doc) = current!(cx.editor);
let path = match doc.path() {
- Some(path) => path.to_path_buf(),
+ Some(path) => path,
None => {
cx.editor
.set_error("Can't start debug: document has no path".to_string());
@@ -304,12 +304,11 @@ pub fn dap_launch(cx: &mut Context) {
}
};
- let config = cx
- .editor
- .syn_loader
- .language_config_for_file_name(&path)
- .and_then(|x| x.debugger.clone());
- let config = match config {
+ let language_config = cx.editor.syn_loader.language_config_for_file_name(path);
+ let config = match language_config
+ .as_deref()
+ .and_then(|config| config.debugger.as_ref())
+ {
Some(c) => c,
None => {
cx.editor.set_error(
@@ -321,7 +320,7 @@ pub fn dap_launch(cx: &mut Context) {
cx.push_layer(Box::new(Picker::new(
true,
- config.templates,
+ config.templates.clone(),
|template| template.name.as_str().into(),
|cx, template, _action| {
let completions = template.completion.clone();