mirror of
https://github.com/helix-editor/helix.git
synced 2024-11-22 17:36:19 +04:00
fix: prevents storing last prompt if is top of stack (#3609)
This commit is contained in:
parent
ee94031fc4
commit
1cbf552554
@ -1977,7 +1977,7 @@ fn extend_line_impl(cx: &mut Context, extend: Extend) {
|
|||||||
let end = text.line_to_char(
|
let end = text.line_to_char(
|
||||||
match extend {
|
match extend {
|
||||||
Extend::Above => end_line + 1, // the start of next line
|
Extend::Above => end_line + 1, // the start of next line
|
||||||
Extend::Below => (end_line + count),
|
Extend::Below => end_line + count,
|
||||||
}
|
}
|
||||||
.min(text.len_lines()),
|
.min(text.len_lines()),
|
||||||
);
|
);
|
||||||
|
@ -533,18 +533,24 @@ fn handle_event(&mut self, event: &Event, cx: &mut Context) -> EventResult {
|
|||||||
if self.selection.is_some() && self.line.ends_with(std::path::MAIN_SEPARATOR) {
|
if self.selection.is_some() && self.line.ends_with(std::path::MAIN_SEPARATOR) {
|
||||||
self.recalculate_completion(cx.editor);
|
self.recalculate_completion(cx.editor);
|
||||||
} else {
|
} 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
|
// handle executing with last command in history if nothing entered
|
||||||
let input: Cow<str> = if self.line.is_empty() {
|
let input: Cow<str> = if self.line.is_empty() {
|
||||||
// latest value in the register list
|
last_item
|
||||||
self.history_register
|
|
||||||
.and_then(|reg| cx.editor.registers.last(reg).cloned())
|
|
||||||
.map(|entry| entry.into())
|
|
||||||
.unwrap_or_else(|| Cow::from(""))
|
|
||||||
} else {
|
} else {
|
||||||
if let Some(register) = self.history_register {
|
if last_item != self.line {
|
||||||
// store in history
|
// store in history
|
||||||
let register = cx.editor.registers.get_mut(register);
|
if let Some(register) = self.history_register {
|
||||||
register.push(self.line.clone());
|
cx.editor
|
||||||
|
.registers
|
||||||
|
.get_mut(register)
|
||||||
|
.push(self.line.clone());
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
self.line.as_str().into()
|
self.line.as_str().into()
|
||||||
|
Loading…
Reference in New Issue
Block a user