Maintain cursor in history prefix search

The search term highlighting looks looks really bad on the default theme
because the command is highlighted as dark blue and the search term adds
a dark background.  If this new feature motivates us to finally fix this,
that would be great.

Closes #10430
This commit is contained in:
Johannes Altmanninger 2024-04-12 13:03:37 +02:00
parent 90cffb18a1
commit 1dd901e521
2 changed files with 5 additions and 0 deletions

View File

@ -115,6 +115,7 @@ New or improved bindings
- 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`.
- ``backward-kill-path-component`` and friends now treat ``#`` as part of a path component (:issue:`10271`).
- Bindings like :kbd:`alt-l` that print output in between prompts now work correctly with multiline commandlines.
- `history-prefix-search-{backward,forward}` now maintain the cursor position instead of moving the cursor to the end of the command line (:issue:`10430`).
- The ``E`` binding in vi mode now correctly handles the last character of the word, by jumping to the next word (:issue:`9700`).
- If the terminal supports shifted key codes from the [kitty keyboard protocol](https://sw.kovidgoyal.net/kitty/keyboard-protocol/), ``shift-enter`` now inserts a newline instead of executing the command line.
- Vi mode has seen some improvements but continues to suffer from the lack of people working on it.

View File

@ -1595,6 +1595,10 @@ impl ReaderData {
0..self.command_line.len(),
new_text,
);
if self.history_search.by_prefix() {
self.command_line
.set_position(self.history_search.search_string().len());
}
}
self.command_line_has_transient_edit = true;
self.update_buff_pos(EditableLineTag::Commandline, None);