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 #3411
This commit is contained in:
Dmytro Maluka 2024-08-04 13:36:59 +02:00
parent 2259fd10af
commit 658c20ff2a

View File

@ -293,7 +293,6 @@ func (eh *EventHandler) UndoOneEvent() {
// Set the cursor in the right place // Set the cursor in the right place
teCursor := t.C teCursor := t.C
if teCursor.Num >= 0 && teCursor.Num < len(eh.cursors) { if teCursor.Num >= 0 && teCursor.Num < len(eh.cursors) {
t.C = *eh.cursors[teCursor.Num]
eh.cursors[teCursor.Num].Goto(teCursor) eh.cursors[teCursor.Num].Goto(teCursor)
eh.cursors[teCursor.Num].NewTrailingWsY = teCursor.NewTrailingWsY eh.cursors[teCursor.Num].NewTrailingWsY = teCursor.NewTrailingWsY
} else { } else {
@ -338,7 +337,6 @@ func (eh *EventHandler) RedoOneEvent() {
teCursor := t.C teCursor := t.C
if teCursor.Num >= 0 && teCursor.Num < len(eh.cursors) { if teCursor.Num >= 0 && teCursor.Num < len(eh.cursors) {
t.C = *eh.cursors[teCursor.Num]
eh.cursors[teCursor.Num].Goto(teCursor) eh.cursors[teCursor.Num].Goto(teCursor)
eh.cursors[teCursor.Num].NewTrailingWsY = teCursor.NewTrailingWsY eh.cursors[teCursor.Num].NewTrailingWsY = teCursor.NewTrailingWsY
} else { } else {