aboutsummaryrefslogtreecommitdiff
path: root/helix-term/src/ui/mod.rs
diff options
context:
space:
mode:
authorBlaž Hrastnik2021-09-08 05:52:09 +0000
committerBlaž Hrastnik2021-09-08 07:34:04 +0000
commit72cf86e4626c01c6ce2371c7b134ab7a7041620c (patch)
tree41a97f105e5dd5e0fb68ec2b99727e67545641b5 /helix-term/src/ui/mod.rs
parent011f9aa47f2316f120da48d342430c7c5caaf107 (diff)
Regex prompts should have a history with a specifiable register
Diffstat (limited to 'helix-term/src/ui/mod.rs')
-rw-r--r--helix-term/src/ui/mod.rs9
1 files changed, 4 insertions, 5 deletions
diff --git a/helix-term/src/ui/mod.rs b/helix-term/src/ui/mod.rs
index 0a1e24b5..07eef352 100644
--- a/helix-term/src/ui/mod.rs
+++ b/helix-term/src/ui/mod.rs
@@ -20,7 +20,6 @@ pub use spinner::{ProgressSpinners, Spinner};
pub use text::Text;
use helix_core::regex::Regex;
-use helix_core::register::Registers;
use helix_view::{Document, Editor, View};
use std::path::PathBuf;
@@ -28,7 +27,8 @@ use std::path::PathBuf;
pub fn regex_prompt(
cx: &mut crate::commands::Context,
prompt: std::borrow::Cow<'static, str>,
- fun: impl Fn(&mut View, &mut Document, &mut Registers, Regex) + 'static,
+ history_register: Option<char>,
+ fun: impl Fn(&mut View, &mut Document, Regex) + 'static,
) -> Prompt {
let (view, doc) = current!(cx.editor);
let view_id = view.id;
@@ -36,7 +36,7 @@ pub fn regex_prompt(
Prompt::new(
prompt,
- None,
+ history_register,
|_input: &str| Vec::new(), // this is fine because Vec::new() doesn't allocate
move |cx: &mut crate::compositor::Context, input: &str, event: PromptEvent| {
match event {
@@ -56,12 +56,11 @@ pub fn regex_prompt(
match Regex::new(input) {
Ok(regex) => {
let (view, doc) = current!(cx.editor);
- let registers = &mut cx.editor.registers;
// revert state to what it was before the last update
doc.set_selection(view.id, snapshot.clone());
- fun(view, doc, registers, regex);
+ fun(view, doc, regex);
view.ensure_cursor_in_view(doc, cx.editor.config.scrolloff);
}