Skip to content

Commit 134cd99

Browse files
committed
Reset LastVisualX on undo/redo
In cursor's Goto(), which is currently only used by undo and redo, we restore remembered LastVisualX and LastWrappedVisualX values. But if the window had been resized in the meantime, the LastWrappedVisualX may not be valid anymore. So it may cause the cursor moving to unexpected locations. So for simplicity just reset these values on undo or redo, instead of using remembered ones.
1 parent 6214abb commit 134cd99

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

internal/buffer/cursor.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,9 @@ func (c *Cursor) Buf() *Buffer {
6767
// Goto puts the cursor at the given cursor's location and gives
6868
// the current cursor its selection too
6969
func (c *Cursor) Goto(b Cursor) {
70-
c.X, c.Y, c.LastVisualX, c.LastWrappedVisualX = b.X, b.Y, b.LastVisualX, b.LastWrappedVisualX
70+
c.X, c.Y = b.X, b.Y
7171
c.OrigSelection, c.CurSelection = b.OrigSelection, b.CurSelection
72+
c.StoreVisualX()
7273
}
7374

7475
// GotoLoc puts the cursor at the given cursor's location and gives

0 commit comments

Comments
 (0)