]> git.lizzy.rs Git - micro.git/blobdiff - cmd/micro/cursor.go
Merge pull request #1242 from dwwmmn/dwwmmn-erl
[micro.git] / cmd / micro / cursor.go
index 452268ba12b1f3802623be7fca8c5d33097e81e0..15dbb1b360bdf3da7903c18a6b0edf1ab8c63e76 100644 (file)
@@ -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)
        }
@@ -333,7 +331,7 @@ func (c *Cursor) Start() {
        c.LastVisualX = c.GetVisualX()
 }
 
-// StartOfText moves the cursor to the first non-whitespace rune of 
+// StartOfText moves the cursor to the first non-whitespace rune of
 // the line it is on
 func (c *Cursor) StartOfText() {
        c.Start()