Make regex_prompt directly call cx.push_layer
This commit is contained in:
parent
83b3272166
commit
5c162ef995
3 changed files with 9 additions and 26 deletions
|
@ -1411,7 +1411,7 @@ fn select_all(cx: &mut Context) {
|
|||
|
||||
fn select_regex(cx: &mut Context) {
|
||||
let reg = cx.register.unwrap_or('/');
|
||||
let prompt = ui::regex_prompt(
|
||||
ui::regex_prompt(
|
||||
cx,
|
||||
"select:".into(),
|
||||
Some(reg),
|
||||
|
@ -1428,13 +1428,11 @@ fn select_regex(cx: &mut Context) {
|
|||
}
|
||||
},
|
||||
);
|
||||
|
||||
cx.push_layer(Box::new(prompt));
|
||||
}
|
||||
|
||||
fn split_selection(cx: &mut Context) {
|
||||
let reg = cx.register.unwrap_or('/');
|
||||
let prompt = ui::regex_prompt(
|
||||
ui::regex_prompt(
|
||||
cx,
|
||||
"split:".into(),
|
||||
Some(reg),
|
||||
|
@ -1448,8 +1446,6 @@ fn split_selection(cx: &mut Context) {
|
|||
doc.set_selection(view.id, selection);
|
||||
},
|
||||
);
|
||||
|
||||
cx.push_layer(Box::new(prompt));
|
||||
}
|
||||
|
||||
fn split_selection_on_newline(cx: &mut Context) {
|
||||
|
@ -1578,7 +1574,7 @@ fn searcher(cx: &mut Context, direction: Direction) {
|
|||
let contents = doc.text().slice(..).to_string();
|
||||
let completions = search_completions(cx, Some(reg));
|
||||
|
||||
let prompt = ui::regex_prompt(
|
||||
ui::regex_prompt(
|
||||
cx,
|
||||
"search:".into(),
|
||||
Some(reg),
|
||||
|
@ -1605,8 +1601,6 @@ fn searcher(cx: &mut Context, direction: Direction) {
|
|||
);
|
||||
},
|
||||
);
|
||||
|
||||
cx.push_layer(Box::new(prompt));
|
||||
}
|
||||
|
||||
fn search_next_or_prev_impl(cx: &mut Context, movement: Movement, direction: Direction) {
|
||||
|
@ -1682,7 +1676,7 @@ fn global_search(cx: &mut Context) {
|
|||
let file_picker_config = config.file_picker.clone();
|
||||
|
||||
let completions = search_completions(cx, None);
|
||||
let prompt = ui::regex_prompt(
|
||||
ui::regex_prompt(
|
||||
cx,
|
||||
"global-search:".into(),
|
||||
None,
|
||||
|
@ -1764,8 +1758,6 @@ fn global_search(cx: &mut Context) {
|
|||
},
|
||||
);
|
||||
|
||||
cx.push_layer(Box::new(prompt));
|
||||
|
||||
let current_path = doc_mut!(cx.editor).path().cloned();
|
||||
|
||||
let show_picker = async move {
|
||||
|
@ -3400,7 +3392,7 @@ fn join_selections(cx: &mut Context) {
|
|||
fn keep_or_remove_selections_impl(cx: &mut Context, remove: bool) {
|
||||
// keep or remove selections matching regex
|
||||
let reg = cx.register.unwrap_or('/');
|
||||
let prompt = ui::regex_prompt(
|
||||
ui::regex_prompt(
|
||||
cx,
|
||||
if remove { "remove:" } else { "keep:" }.into(),
|
||||
Some(reg),
|
||||
|
@ -3417,9 +3409,7 @@ fn keep_or_remove_selections_impl(cx: &mut Context, remove: bool) {
|
|||
doc.set_selection(view.id, selection);
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
cx.push_layer(Box::new(prompt));
|
||||
)
|
||||
}
|
||||
|
||||
fn keep_selections(cx: &mut Context) {
|
||||
|
|
|
@ -9,14 +9,6 @@ use tui::buffer::Buffer as Surface;
|
|||
|
||||
pub type Callback = Box<dyn FnOnce(&mut Compositor, &mut Context)>;
|
||||
|
||||
// --> EventResult should have a callback that takes a context with methods like .popup(),
|
||||
// .prompt() etc. That way we can abstract it from the renderer.
|
||||
// Q: How does this interact with popups where we need to be able to specify the rendering of the
|
||||
// popup?
|
||||
// A: It could just take a textarea.
|
||||
//
|
||||
// If Compositor was specified in the callback that's then problematic because of
|
||||
|
||||
// Cursive-inspired
|
||||
pub enum EventResult {
|
||||
Ignored(Option<Callback>),
|
||||
|
|
|
@ -32,7 +32,7 @@ pub fn regex_prompt(
|
|||
history_register: Option<char>,
|
||||
completion_fn: impl FnMut(&Editor, &str) -> Vec<prompt::Completion> + 'static,
|
||||
fun: impl Fn(&mut View, &mut Document, Regex, PromptEvent) + 'static,
|
||||
) -> Prompt {
|
||||
) {
|
||||
let (view, doc) = current!(cx.editor);
|
||||
let doc_id = view.doc;
|
||||
let snapshot = doc.selection(view.id).clone();
|
||||
|
@ -95,7 +95,8 @@ pub fn regex_prompt(
|
|||
);
|
||||
// Calculate initial completion
|
||||
prompt.recalculate_completion(cx.editor);
|
||||
prompt
|
||||
// prompt
|
||||
cx.push_layer(Box::new(prompt));
|
||||
}
|
||||
|
||||
pub fn file_picker(root: PathBuf, config: &helix_view::editor::Config) -> FilePicker<PathBuf> {
|
||||
|
|
Loading…
Add table
Reference in a new issue