Skip to content

Commit

Permalink
Fixed UpN Cursor functionality to properly handle moving from long li…
Browse files Browse the repository at this point in the history
…ne to shorter line
  • Loading branch information
rexy712 committed Aug 25, 2018
1 parent e11d9de commit 6e9b8c1
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions cmd/micro/cursor.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
}
Expand Down

0 comments on commit 6e9b8c1

Please sign in to comment.