Skip to content

Commit 658c20f

Browse files
committed
undo/redo: Don't change remembered cursor location
Remember the cursor location in TextEvent just once - when the original text event happens, so that when we redo after an undo, the cursor is placed at the location where the actual redone modification happens (as the user would expect), not at the location where the cursor was before the undo (which may be a completely unrelated location and may be far away). Fixes zyedidia#3411
1 parent 2259fd1 commit 658c20f

File tree

1 file changed

+0
-2
lines changed

1 file changed

+0
-2
lines changed

internal/buffer/eventhandler.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,6 @@ func (eh *EventHandler) UndoOneEvent() {
293293
// Set the cursor in the right place
294294
teCursor := t.C
295295
if teCursor.Num >= 0 && teCursor.Num < len(eh.cursors) {
296-
t.C = *eh.cursors[teCursor.Num]
297296
eh.cursors[teCursor.Num].Goto(teCursor)
298297
eh.cursors[teCursor.Num].NewTrailingWsY = teCursor.NewTrailingWsY
299298
} else {
@@ -338,7 +337,6 @@ func (eh *EventHandler) RedoOneEvent() {
338337

339338
teCursor := t.C
340339
if teCursor.Num >= 0 && teCursor.Num < len(eh.cursors) {
341-
t.C = *eh.cursors[teCursor.Num]
342340
eh.cursors[teCursor.Num].Goto(teCursor)
343341
eh.cursors[teCursor.Num].NewTrailingWsY = teCursor.NewTrailingWsY
344342
} else {

0 commit comments

Comments
 (0)