Add hack to fix off-by-one error in Vi-mode cancel-commandline

The new cursor-end-mode "inclusive" (which is active in Vi mode) is causing
many issues.

One of them is because cancel-commandline wants to move to the end of the
command line before printing "^C".  Since "inclusive" cursor mode prevents
the cursor from moving past the last character, that one will be overwritten
with a "^".  Hack around this.

Closes #11261

(cherry picked from commit b08ff33291)
This commit is contained in:
Johannes Altmanninger
2025-03-11 19:34:56 +01:00
parent e37e1b8f78
commit 19502ff9e7

View File

@@ -2347,7 +2347,12 @@ fn handle_readline_command(&mut self, c: ReadlineCmd) {
if c == rl::CancelCommandline {
// Move cursor to the end of the line.
let end = self.command_line.len();
self.update_buff_pos(EditableLineTag::Commandline, Some(end));
{
let tmp =
std::mem::replace(&mut self.cursor_end_mode, CursorEndMode::Exclusive);
self.update_buff_pos(EditableLineTag::Commandline, Some(end));
self.cursor_end_mode = tmp;
}
self.autosuggestion.clear();
// Repaint also changes the actual cursor position