diff --git a/cmd/micro/bindings.go b/cmd/micro/bindings.go index 8e201187..5d51feed 100644 --- a/cmd/micro/bindings.go +++ b/cmd/micro/bindings.go @@ -298,6 +298,17 @@ func (v *View) CursorLeft() bool { return true } +// CursorRight moves the cursor right +func (v *View) CursorRight() bool { + if v.cursor.HasSelection() { + v.cursor.SetLoc(v.cursor.curSelection[1] - 1) + v.cursor.ResetSelection() + } else { + v.cursor.Right() + } + return true +} + func (v *View) WordRight() bool { v.cursor.WordRight() return true @@ -334,7 +345,7 @@ func (v *View) SelectWordRight() bool { v.cursor.origSelection[0] = loc } v.cursor.WordRight() - v.cursor.SelectTo(v.cursor.Loc() - 1) + v.cursor.SelectTo(v.cursor.Loc()) return true } @@ -348,17 +359,6 @@ func (v *View) SelectWordLeft() bool { return true } -// CursorRight moves the cursor right -func (v *View) CursorRight() bool { - if v.cursor.HasSelection() { - v.cursor.SetLoc(v.cursor.curSelection[1] - 1) - v.cursor.ResetSelection() - } else { - v.cursor.Right() - } - return true -} - // InsertSpace inserts a space func (v *View) InsertSpace() bool { // Insert a space diff --git a/cmd/micro/cursor.go b/cmd/micro/cursor.go index bea87e3e..b1fd4504 100644 --- a/cmd/micro/cursor.go +++ b/cmd/micro/cursor.go @@ -207,7 +207,7 @@ func (c *Cursor) AddWordToSelection() { func (c *Cursor) SelectTo(loc int) { if loc > c.origSelection[0] { c.curSelection[0] = c.origSelection[0] - c.curSelection[1] = loc + 1 + c.curSelection[1] = loc } else { c.curSelection[0] = loc c.curSelection[1] = c.origSelection[0] + 1 @@ -242,7 +242,7 @@ func (c *Cursor) RuneUnder(x int) rune { return '\n' } if x >= len(line) { - x = len(line) - 1 + return '\n' } else if x < 0 { x = 0 }