aboutsummaryrefslogtreecommitdiff
path: root/helix-term/src/ui
diff options
context:
space:
mode:
authorSaber Haj Rabiee2022-09-01 01:29:15 +0000
committerGitHub2022-09-01 01:29:15 +0000
commit1cbf5525540531f26cd6bd765de93b20d96078f5 (patch)
treef5cbc491ed09218f857ce5ac9d4751c88a4da573 /helix-term/src/ui
parentee94031fc48ca0a4437c543221266a38e8e1ff87 (diff)
fix: prevents storing last prompt if is top of stack (#3609)
Diffstat (limited to 'helix-term/src/ui')
-rw-r--r--helix-term/src/ui/prompt.rs22
1 files changed, 14 insertions, 8 deletions
diff --git a/helix-term/src/ui/prompt.rs b/helix-term/src/ui/prompt.rs
index 1b2c35e9..24fc8233 100644
--- a/helix-term/src/ui/prompt.rs
+++ b/helix-term/src/ui/prompt.rs
@@ -533,18 +533,24 @@ impl Component for Prompt {
if self.selection.is_some() && self.line.ends_with(std::path::MAIN_SEPARATOR) {
self.recalculate_completion(cx.editor);
} else {
+ let last_item = self
+ .history_register
+ .and_then(|reg| cx.editor.registers.last(reg).cloned())
+ .map(|entry| entry.into())
+ .unwrap_or_else(|| Cow::from(""));
+
// handle executing with last command in history if nothing entered
let input: Cow<str> = if self.line.is_empty() {
- // latest value in the register list
- self.history_register
- .and_then(|reg| cx.editor.registers.last(reg).cloned())
- .map(|entry| entry.into())
- .unwrap_or_else(|| Cow::from(""))
+ last_item
} else {
- if let Some(register) = self.history_register {
+ if last_item != self.line {
// store in history
- let register = cx.editor.registers.get_mut(register);
- register.push(self.line.clone());
+ if let Some(register) = self.history_register {
+ cx.editor
+ .registers
+ .get_mut(register)
+ .push(self.line.clone());
+ };
}
self.line.as_str().into()