on master help sign in
fixes showing the last prompt on empty input (#2870)
commit3dbad0442fc3038dd0b0f6bd07ba0e40d2d92000 authorSaber Haj Rabiee <sabify@users.noreply.github.com> dateFri 24 Jun 2022, 08:14 (4 years ago) parentd948ace
2 files changed+6−2
helix-core/src/register.rs+4 helix-term/src/ui/prompt.rs+2−2
helix-core/src/register.rs+4
@@ -73,6 +73,10 @@ impl Registers {
7373 self.read(name).and_then(|entries| entries.first())
7474 }
7575
76+ pub fn last(&self, name: char) -> Option<&String> {
77+ self.read(name).and_then(|entries| entries.last())
78+ }
79+
7680 pub fn inner(&self) -> &HashMap<char, Register> {
7781 &self.inner
7882 }
helix-term/src/ui/prompt.rs+2−2
@@ -443,7 +443,7 @@ impl Prompt {
443443 let input: Cow<str> = if self.line.is_empty() {
444444 // latest value in the register list
445445 self.history_register
446− .and_then(|reg| cx.editor.registers.first(reg))
446+ .and_then(|reg| cx.editor.registers.last(reg))
447447 .map(|entry| entry.into())
448448 .unwrap_or_else(|| Cow::from(""))
449449 } else {
@@ -522,7 +522,7 @@ impl Component for Prompt {
522522 let input: Cow<str> = if self.line.is_empty() {
523523 // latest value in the register list
524524 self.history_register
525− .and_then(|reg| cx.editor.registers.first(reg).cloned())
525+ .and_then(|reg| cx.editor.registers.last(reg).cloned())
526526 .map(|entry| entry.into())
527527 .unwrap_or_else(|| Cow::from(""))
528528 } else {