Merge pull request #3416 from dmaluka/undo-cursor-fix

Fix cursor moving to an unexpected location after a redo
This commit is contained in:
Dmytro Maluka
2024-08-15 16:07:51 +02:00
committed by GitHub

View File

@@ -291,13 +291,9 @@ func (eh *EventHandler) UndoOneEvent() {
eh.UndoTextEvent(t) eh.UndoTextEvent(t)
// Set the cursor in the right place // Set the cursor in the right place
teCursor := t.C if t.C.Num >= 0 && t.C.Num < len(eh.cursors) {
if teCursor.Num >= 0 && teCursor.Num < len(eh.cursors) { eh.cursors[t.C.Num].Goto(t.C)
t.C = *eh.cursors[teCursor.Num] eh.cursors[t.C.Num].NewTrailingWsY = t.C.NewTrailingWsY
eh.cursors[teCursor.Num].Goto(teCursor)
eh.cursors[teCursor.Num].NewTrailingWsY = teCursor.NewTrailingWsY
} else {
teCursor.Num = -1
} }
// Push it to the redo stack // Push it to the redo stack
@@ -336,13 +332,9 @@ func (eh *EventHandler) RedoOneEvent() {
return return
} }
teCursor := t.C if t.C.Num >= 0 && t.C.Num < len(eh.cursors) {
if teCursor.Num >= 0 && teCursor.Num < len(eh.cursors) { eh.cursors[t.C.Num].Goto(t.C)
t.C = *eh.cursors[teCursor.Num] eh.cursors[t.C.Num].NewTrailingWsY = t.C.NewTrailingWsY
eh.cursors[teCursor.Num].Goto(teCursor)
eh.cursors[teCursor.Num].NewTrailingWsY = teCursor.NewTrailingWsY
} else {
teCursor.Num = -1
} }
// Modifies the text event // Modifies the text event