dap: Remove the prompt line parameter, use insert_str instead

pull/574/head
Blaž Hrastnik 3 years ago
parent 5f329a22c4
commit 0eadeab8c7

@ -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));
}

@ -386,7 +386,6 @@ fn debug_parameter_prompt(
);
}
},
None,
)
}
@ -638,8 +637,7 @@ 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(
let mut prompt = Prompt::new(
"condition:".into(),
None,
|_input: &str| Vec::new(),
@ -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)

@ -90,7 +90,6 @@ pub fn regex_prompt(
}
}
},
None,
)
}

@ -301,7 +301,6 @@ impl<T> Picker<T> {
|_editor: &mut Context, _pattern: &str, _event: PromptEvent| {
//
},
None,
);
let mut picker = Self {

@ -61,11 +61,10 @@ impl Prompt {
history_register: Option<char>,
mut completion_fn: impl FnMut(&str) -> Vec<Completion> + 'static,
callback_fn: impl FnMut(&mut Context, &str, PromptEvent) + 'static,
line: Option<String>,
) -> Self {
Self {
prompt,
line: line.unwrap_or_default(),
line: String::new(),
cursor: 0,
completion: completion_fn(""),
selection: None,

Loading…
Cancel
Save