Make shift-delete also delete current autosuggestion

This is a bit more convenient than using "history delete".
This commit is contained in:
Johannes Altmanninger 2024-04-27 09:04:05 +02:00
parent 67197b4b07
commit 301e4d497e
2 changed files with 14 additions and 4 deletions

View file

@ -138,6 +138,7 @@ New or improved bindings
For example, ``commandline -f yank -f yank-pop`` inserts the last-but-one entry from the kill ring.
- When the cursor is on a command that resolves to an executable script, :kbd:`alt-o` will now open that script in your editor (:issue:`10266`).
- During up-arrow history search, :kbd:`shift-delete` will delete the current search item and move to the next older item. Previously this was only supported in the history pager.
Same for autosuggestions.
- Some improvements to the :kbd:`alt-e` binding which edits the commandline in an external editor:
- The editor's cursor position is copied back to fish. This is currently supported for Vim and Kakoune.
- Cursor position synchronization is only supported for a set of known editors. This has been extended by also resolving aliases. For example use ``complete --wraps my-vim vim`` to synchronize cursors when `EDITOR=my-vim`.

View file

@ -2579,11 +2579,20 @@ impl ReaderData {
}
rl::HistoryPagerDelete => {
// Also applies to ordinary history search.
if !self.history_search.is_at_end() {
self.history.remove(self.history_search.current_result());
let is_history_search = !self.history_search.is_at_end();
if is_history_search || !self.autosuggestion.is_empty() {
self.history.remove(if is_history_search {
self.history_search.current_result()
} else {
&self.autosuggestion.text
});
self.history.save();
self.history_search.handle_deletion();
self.update_command_line_from_history_search();
if is_history_search {
self.history_search.handle_deletion();
self.update_command_line_from_history_search();
} else {
self.autosuggestion.clear();
}
self.inputter.function_set_status(true);
return;
}