Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'helix-term/src/ui/prompt.rs')
-rw-r--r--helix-term/src/ui/prompt.rs23
1 files changed, 12 insertions, 11 deletions
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