diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 6bc5bfd20..75aa218fb 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -60,6 +60,7 @@ Notable improvements and fixes Any key argument that starts with an ASCII control character (like ``\e`` or ``\cX``) or is up to 3 characters long and not a named key and does not contain ``,`` or ``-`` will be interpreted in the old syntax to keep compatibility for the majority of bindings. This should cover the majority of bindings in use. - A new function ``fish_should_add_to_history`` can be overridden to decide whether a command should be added to the history (:issue:`10302`). - :kbd:`ctrl-c` during command input no longer prints ``^C`` and a new prompt but merely clears the command line. This restores the behavior from version 2.2. To revert to the old behavior use ``bind ctrl-c __fish_cancel_commandline`` (:issue:`10213`). +- Undo history is no longer truncated after every command but kept for the lifetime of the shell process. - The :kbd:`ctrl-r` history search now uses glob syntax (:issue:`10131`). - The :kbd:`ctrl-r` history search now operates only on the line at cursor, making it easier to quickly compose a multi-line command by recalling previous commands. - Abbreviations can now be restricted to specific commands. For instance:: diff --git a/src/editable_line.rs b/src/editable_line.rs index 2869ceee6..c30622944 100644 --- a/src/editable_line.rs +++ b/src/editable_line.rs @@ -160,17 +160,13 @@ impl EditableLine { } pub fn clear(&mut self) { - self.undo_history.clear(); if self.is_empty() { return; } - let len = self.len(); - apply_edit( - &mut self.text, - &mut self.colors, - &Edit::new(0..len, L!("").to_owned()), + self.push_edit( + Edit::new(0..self.len(), L!("").to_owned()), + /*allow_coalesce=*/ false, ); - self.set_position(0); } /// Modify the commandline according to @edit. Most modifications to the diff --git a/src/reader.rs b/src/reader.rs index c507727b2..0acf0cc4b 100644 --- a/src/reader.rs +++ b/src/reader.rs @@ -625,8 +625,8 @@ fn read_i(parser: &Parser) -> i32 { continue; } - data.update_buff_pos(EditableLineTag::Commandline, Some(0)); data.command_line.clear(); + data.update_buff_pos(EditableLineTag::Commandline, None); data.command_line_changed(EditableLineTag::Commandline); data.screen.write_bytes(b"\x1b]133;C\x07"); event::fire_generic(parser, L!("fish_preexec").to_owned(), vec![command.clone()]);