From 134cd999c60b84c16c7d68b2ea629897b626a49a Mon Sep 17 00:00:00 2001 From: Dmytro Maluka Date: Sun, 13 Oct 2024 23:14:37 +0200 Subject: [PATCH] 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. --- internal/buffer/cursor.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/internal/buffer/cursor.go b/internal/buffer/cursor.go index 007fcbe5..d849f836 100644 --- a/internal/buffer/cursor.go +++ b/internal/buffer/cursor.go @@ -67,8 +67,9 @@ func (c *Cursor) Buf() *Buffer { // Goto puts the cursor at the given cursor's location and gives // the current cursor its selection too func (c *Cursor) Goto(b Cursor) { - c.X, c.Y, c.LastVisualX, c.LastWrappedVisualX = b.X, b.Y, b.LastVisualX, b.LastWrappedVisualX + c.X, c.Y = b.X, b.Y c.OrigSelection, c.CurSelection = b.OrigSelection, b.CurSelection + c.StoreVisualX() } // GotoLoc puts the cursor at the given cursor's location and gives