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 Component for Picker Option { + 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