fixes showing the last prompt on empty input (#2870)

imgbot
Saber Haj Rabiee 2 years ago committed by GitHub
parent d948ace67b
commit 3dbad0442f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -73,6 +73,10 @@ impl Registers {
self.read(name).and_then(|entries| entries.first()) self.read(name).and_then(|entries| entries.first())
} }
pub fn last(&self, name: char) -> Option<&String> {
self.read(name).and_then(|entries| entries.last())
}
pub fn inner(&self) -> &HashMap<char, Register> { pub fn inner(&self) -> &HashMap<char, Register> {
&self.inner &self.inner
} }

@ -443,7 +443,7 @@ impl Prompt {
let input: Cow<str> = if self.line.is_empty() { let input: Cow<str> = if self.line.is_empty() {
// latest value in the register list // latest value in the register list
self.history_register self.history_register
.and_then(|reg| cx.editor.registers.first(reg)) .and_then(|reg| cx.editor.registers.last(reg))
.map(|entry| entry.into()) .map(|entry| entry.into())
.unwrap_or_else(|| Cow::from("")) .unwrap_or_else(|| Cow::from(""))
} else { } else {
@ -522,7 +522,7 @@ impl Component for Prompt {
let input: Cow<str> = if self.line.is_empty() { let input: Cow<str> = if self.line.is_empty() {
// latest value in the register list // latest value in the register list
self.history_register self.history_register
.and_then(|reg| cx.editor.registers.first(reg).cloned()) .and_then(|reg| cx.editor.registers.last(reg).cloned())
.map(|entry| entry.into()) .map(|entry| entry.into())
.unwrap_or_else(|| Cow::from("")) .unwrap_or_else(|| Cow::from(""))
} else { } else {

Loading…
Cancel
Save