Fix restoring cursor position on redo with edit groups

This commit is contained in:
Johannes Altmanninger 2024-04-13 08:12:21 +02:00
parent d1a4b4bc73
commit edb5cb7226
2 changed files with 18 additions and 2 deletions

View File

@ -278,7 +278,8 @@ impl EditableLine {
last_group_id = edit.group_id;
self.undo_history.edits_applied += 1;
apply_edit(&mut self.text, &mut self.colors, edit);
self.set_position(edit.cursor_position_before_undo.unwrap());
edit.cursor_position_before_undo
.map(|pos| self.set_position(pos));
did_redo = true;
}

View File

@ -24,5 +24,20 @@ expect_str("echo word")
send("Undo")
expect_str("echo")
send("Redo")
send("Redo\r")
expect_str("echo word")
sendline("bind x begin-undo-group 'commandline -i \"+ \"' 'commandline -i 3' end-undo-group")
send("math 2 x\r")
expect_prompt("5")
send("math 4x")
send("Undo1\r")
expect_prompt("41")
send("math 5 x")
send("\x02") # c-b, moving before the 3
send("Undo")
send("Redo")
send("9\r") # 5 + 93
expect_prompt("98")