Improve WordRight and WordLeft bindings

This commit is contained in:
Zachary Yedidia
2016-04-26 09:53:46 -04:00
parent e00e0cfa3f
commit 6c99eea610
2 changed files with 22 additions and 7 deletions

View File

@@ -215,17 +215,24 @@ func (c *Cursor) SelectTo(loc int) {
}
func (c *Cursor) WordRight() {
c.Right()
for !IsWordChar(string(c.RuneUnder(c.x))) {
c.Right()
}
for IsWordChar(string(c.RuneUnder(c.x))) {
c.Right()
}
c.Right()
}
func (c *Cursor) WordLeft() {
c.Left()
for !IsWordChar(string(c.RuneUnder(c.x))) {
c.Left()
}
for IsWordChar(string(c.RuneUnder(c.x))) {
c.Left()
}
c.Left()
c.Right()
}
// RuneUnder returns the rune under the given x position