From 0eadeab8c7c3f1ddc794661782ebbe19ddf5311e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bla=C5=BE=20Hrastnik?= Date: Mon, 22 Nov 2021 11:13:22 +0900 Subject: [PATCH] dap: Remove the prompt line parameter, use insert_str instead --- helix-term/src/commands.rs | 4 ---- helix-term/src/commands/dap.rs | 19 ++++++++++--------- helix-term/src/ui/mod.rs | 1 - helix-term/src/ui/picker.rs | 1 - helix-term/src/ui/prompt.rs | 3 +-- 5 files changed, 11 insertions(+), 17 deletions(-) diff --git a/helix-term/src/commands.rs b/helix-term/src/commands.rs index 56b31b670..54466c569 100644 --- a/helix-term/src/commands.rs +++ b/helix-term/src/commands.rs @@ -2839,7 +2839,6 @@ fn command_mode(cx: &mut Context) { .set_error(format!("no such command: '{}'", parts[0])); }; }, - None, ); prompt.doc_fn = Box::new(|input: &str| { let part = input.split(' ').next().unwrap_or_default(); @@ -5440,7 +5439,6 @@ fn shell_keep_pipe(cx: &mut Context) { let index = index.unwrap_or_else(|| ranges.len() - 1); doc.set_selection(view.id, Selection::new(ranges, index)); }, - None, ); cx.push_layer(Box::new(prompt)); @@ -5544,7 +5542,6 @@ fn shell(cx: &mut Context, prompt: Cow<'static, str>, behavior: ShellBehavior) { // make sure cursor is in view and update scroll as well view.ensure_cursor_in_view(doc, cx.editor.config.scrolloff); }, - None, ); cx.push_layer(Box::new(prompt)); @@ -5622,7 +5619,6 @@ fn rename_symbol(cx: &mut Context) { log::debug!("Edits from LSP: {:?}", edits); apply_workspace_edit(&mut cx.editor, offset_encoding, &edits); }, - None, ); cx.push_layer(Box::new(prompt)); } diff --git a/helix-term/src/commands/dap.rs b/helix-term/src/commands/dap.rs index 113bacd99..e117baffb 100644 --- a/helix-term/src/commands/dap.rs +++ b/helix-term/src/commands/dap.rs @@ -386,7 +386,6 @@ fn debug_parameter_prompt( ); } }, - None, ) } @@ -638,9 +637,8 @@ pub fn dap_edit_condition(cx: &mut Context) { let callback = Box::pin(async move { let call: Callback = Box::new(move |_editor: &mut Editor, compositor: &mut Compositor| { - let condition = breakpoint.condition; - let prompt = Prompt::new( - "condition: ".into(), + let mut prompt = Prompt::new( + "condition:".into(), None, |_input: &str| Vec::new(), move |cx: &mut crate::compositor::Context, @@ -699,8 +697,10 @@ pub fn dap_edit_condition(cx: &mut Context) { } } }, - condition, ); + if let Some(condition) = breakpoint.condition { + prompt.insert_str(&condition) + } compositor.push(Box::new(prompt)); }); Ok(call) @@ -714,9 +714,8 @@ pub fn dap_edit_log(cx: &mut Context) { let callback = Box::pin(async move { let call: Callback = Box::new(move |_editor: &mut Editor, compositor: &mut Compositor| { - let log_message = breakpoint.log_message; - let prompt = Prompt::new( - "log message: ".into(), + let mut prompt = Prompt::new( + "log-message:".into(), None, |_input: &str| Vec::new(), move |cx: &mut crate::compositor::Context, @@ -775,8 +774,10 @@ pub fn dap_edit_log(cx: &mut Context) { } } }, - log_message, ); + if let Some(log_message) = breakpoint.log_message { + prompt.insert_str(&log_message); + } compositor.push(Box::new(prompt)); }); Ok(call) diff --git a/helix-term/src/ui/mod.rs b/helix-term/src/ui/mod.rs index 0915937d6..9d3b0bc54 100644 --- a/helix-term/src/ui/mod.rs +++ b/helix-term/src/ui/mod.rs @@ -90,7 +90,6 @@ pub fn regex_prompt( } } }, - None, ) } diff --git a/helix-term/src/ui/picker.rs b/helix-term/src/ui/picker.rs index 2b2e47a4e..eaca470e9 100644 --- a/helix-term/src/ui/picker.rs +++ b/helix-term/src/ui/picker.rs @@ -301,7 +301,6 @@ impl Picker { |_editor: &mut Context, _pattern: &str, _event: PromptEvent| { // }, - None, ); let mut picker = Self { diff --git a/helix-term/src/ui/prompt.rs b/helix-term/src/ui/prompt.rs index 00ffdccf1..e90b07727 100644 --- a/helix-term/src/ui/prompt.rs +++ b/helix-term/src/ui/prompt.rs @@ -61,11 +61,10 @@ impl Prompt { history_register: Option, mut completion_fn: impl FnMut(&str) -> Vec + 'static, callback_fn: impl FnMut(&mut Context, &str, PromptEvent) + 'static, - line: Option, ) -> Self { Self { prompt, - line: line.unwrap_or_default(), + line: String::new(), cursor: 0, completion: completion_fn(""), selection: None,