mirror of
https://github.com/zyedidia/micro.git
synced 2026-02-05 22:50:21 +09:00
Correct word movement behavior
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user