Unnamed repository; edit this file 'description' to name the repository.
-rw-r--r--helix-term/src/ui/picker.rs10
-rw-r--r--helix-term/src/ui/prompt.rs23
2 files changed, 21 insertions, 12 deletions
diff --git a/helix-term/src/ui/picker.rs b/helix-term/src/ui/picker.rs
index e2d15ed2..ffec0fd8 100644
--- a/helix-term/src/ui/picker.rs
+++ b/helix-term/src/ui/picker.rs
@@ -1031,9 +1031,17 @@ impl<I: 'static + Send + Sync, D: 'static + Send + Sync> Component for Picker<I,
self.handle_prompt_change();
} else {
if let Some(option) = self.selection() {
- self.prompt.save_line_to_history(ctx.editor);
(self.callback_fn)(ctx, option, Action::Replace);
}
+ if let Some(history_register) = self.prompt.history_register() {
+ if let Err(err) = ctx
+ .editor
+ .registers
+ .push(history_register, self.primary_query().to_string())
+ {
+ ctx.editor.set_error(err.to_string());
+ }
+ }
return close_fn(self);
}
}
diff --git a/helix-term/src/ui/prompt.rs b/helix-term/src/ui/prompt.rs
index 1ba014f5..6ba2fcb9 100644
--- a/helix-term/src/ui/prompt.rs
+++ b/helix-term/src/ui/prompt.rs
@@ -128,6 +128,10 @@ impl Prompt {
self
}
+ pub(crate) fn history_register(&self) -> Option<char> {
+ self.history_register
+ }
+
pub(crate) fn first_history_completion<'a>(
&'a self,
editor: &'a Editor,
@@ -516,16 +520,6 @@ impl Prompt {
surface.set_string(line_area.x, line_area.y, self.line.clone(), prompt_color);
}
}
-
- /// Saves the current line to the configured history register, if there is one.
- pub(crate) fn save_line_to_history(&self, editor: &mut Editor) {
- let Some(register) = self.history_register else {
- return;
- };
- if let Err(err) = editor.registers.push(register, self.line.clone()) {
- editor.set_error(err.to_string());
- }
- }
}
impl Component for Prompt {
@@ -613,7 +607,14 @@ impl Component for Prompt {
&last_item
} else {
if last_item != self.line {
- self.save_line_to_history(cx.editor);
+ // store in history
+ if let Some(register) = self.history_register {
+ if let Err(err) =
+ cx.editor.registers.push(register, self.line.clone())
+ {
+ cx.editor.set_error(err.to_string());
+ }
+ };
}
&self.line