From 6e9b8c1bd5897f0b636771397e99de301f3489f0 Mon Sep 17 00:00:00 2001 From: rexy712 Date: Sat, 25 Aug 2018 14:49:58 -0700 Subject: [PATCH] Fixed UpN Cursor functionality to properly handle moving from long line to shorter line --- cmd/micro/cursor.go | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/cmd/micro/cursor.go b/cmd/micro/cursor.go index 257096cd..15dbb1b3 100644 --- a/cmd/micro/cursor.go +++ b/cmd/micro/cursor.go @@ -255,7 +255,6 @@ func (c *Cursor) RuneUnder(x int) rune { } return line[x] } - // UpN moves the cursor up N lines (if possible) func (c *Cursor) UpN(amount int) { proposedY := c.Y - amount @@ -266,9 +265,8 @@ func (c *Cursor) UpN(amount int) { proposedY = c.buf.NumLines - 1 } - runes := []rune(c.buf.Line(c.Y)) + runes := []rune(c.buf.Line(proposedY)) c.X = c.GetCharPosInLine(proposedY, c.LastVisualX) - if c.X > len(runes) || (amount < 0 && proposedY == c.Y) { c.X = len(runes) }