Support multiple arguments for debug configs

pull/574/head
Dmitry Sharshakov 3 years ago
parent 2d42766a71
commit 9d2f2a9e32
No known key found for this signature in database
GPG Key ID: 471FD32E15FD8473

@ -1,6 +1,7 @@
use crate::{ use crate::{
commands, commands,
compositor::{Component, Context, EventResult}, compositor::{Component, Compositor, Context, EventResult},
job::Callback,
key, key,
keymap::{KeymapResult, Keymaps}, keymap::{KeymapResult, Keymaps},
ui::{Completion, ProgressSpinners}, ui::{Completion, ProgressSpinners},
@ -709,12 +710,11 @@ impl EditorView {
); );
} }
fn request_parameter( fn debug_parameter_prompt(
completions: Vec<String>, completions: Vec<String>,
config_name: String, config_name: String,
cxt: &mut commands::Context,
mut params: Vec<String>, mut params: Vec<String>,
) { ) -> Prompt {
let noop = |_input: &str| Vec::new(); let noop = |_input: &str| Vec::new();
let completer = match completions.get(0).map(|x| x.as_str()) { let completer = match completions.get(0).map(|x| x.as_str()) {
Some("filename") => super::completers::filename, Some("filename") => super::completers::filename,
@ -725,7 +725,7 @@ impl EditorView {
} }
None => noop, None => noop,
}; };
let prompt = Prompt::new( Prompt::new(
"arg: ".to_owned(), "arg: ".to_owned(),
None, None,
completer, completer,
@ -737,13 +737,19 @@ impl EditorView {
params.push(input.to_owned()); params.push(input.to_owned());
if params.len() < completions.len() { if params.len() < completions.len() {
todo!(); let completions = completions.clone();
// Self::request_parameter( let config_name = config_name.clone();
// completions.clone(), let params = params.clone();
// config_name.clone(), let callback = Box::pin(async move {
// cxt, let call: Callback =
// params.clone(), Box::new(move |_editor: &mut Editor, compositor: &mut Compositor| {
// ); let prompt =
Self::debug_parameter_prompt(completions, config_name, params);
compositor.push(Box::new(prompt));
});
Ok(call)
});
cx.jobs.callback(callback);
} else { } else {
commands::dap_start_impl( commands::dap_start_impl(
cx.editor, cx.editor,
@ -753,8 +759,7 @@ impl EditorView {
); );
} }
}, },
); )
cxt.push_layer(Box::new(prompt));
} }
/// Handle events by looking them up in `self.keymaps`. Returns None /// Handle events by looking them up in `self.keymaps`. Returns None
@ -785,7 +790,8 @@ impl EditorView {
let completions = cxt.editor.debug_config_completions.clone().unwrap(); let completions = cxt.editor.debug_config_completions.clone().unwrap();
let completion = completions.get(i).unwrap().clone(); let completion = completions.get(i).unwrap().clone();
if !completion.is_empty() { if !completion.is_empty() {
Self::request_parameter(completion, name, cxt, Vec::new()); let prompt = Self::debug_parameter_prompt(completion, name, Vec::new());
cxt.push_layer(Box::new(prompt));
} }
} }
_ => return None, _ => return None,

@ -173,8 +173,8 @@ args = { mode = "exec", program = "{0}" }
[[language.debugger.templates]] [[language.debugger.templates]]
name = "test" name = "test"
request = "launch" request = "launch"
completion = [ "directory" ] completion = [ "directory", "directory" ]
args = { mode = "test", program = "{0}" } args = { mode = "test", program = "{0}", output = "{1}" }
[[language.debugger.templates]] [[language.debugger.templates]]
name = "attach" name = "attach"

Loading…
Cancel
Save