mirror of https://github.com/chzyer/readline.git
I updated the switch in vim.go to treat 'w' and 'W' differently to 'e' and 'E'. I then added a method to runebuf.go to provide the logic for that motion. tested and working.
This commit is contained in:
parent
cffdf641d1
commit
47d43db0fd
22
runebuf.go
22
runebuf.go
|
@ -259,6 +259,28 @@ func (r *RuneBuffer) MoveToNextWord() {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (r *RuneBuffer) MoveToEndWord() {
|
||||||
|
r.Refresh(func() {
|
||||||
|
// already at the end, so do nothing
|
||||||
|
if r.idx == len(r.buf) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
// if we are at the end of a word already, go to next
|
||||||
|
if !IsWordBreak(r.buf[r.idx]) && IsWordBreak(r.buf[r.idx+1]) {
|
||||||
|
r.idx++
|
||||||
|
}
|
||||||
|
|
||||||
|
// keep going until at the end of a word
|
||||||
|
for i := r.idx + 1; i < len(r.buf); i++ {
|
||||||
|
if IsWordBreak(r.buf[i]) && !IsWordBreak(r.buf[i-1]) {
|
||||||
|
r.idx = i - 1
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
r.idx = len(r.buf)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
func (r *RuneBuffer) BackEscapeWord() {
|
func (r *RuneBuffer) BackEscapeWord() {
|
||||||
r.Refresh(func() {
|
r.Refresh(func() {
|
||||||
if r.idx == 0 {
|
if r.idx == 0 {
|
||||||
|
|
4
vim.go
4
vim.go
|
@ -74,8 +74,10 @@ func (o *opVim) handleVimNormalMovement(r rune, readNext func() rune) (t rune, h
|
||||||
}
|
}
|
||||||
case 'b', 'B':
|
case 'b', 'B':
|
||||||
rb.MoveToPrevWord()
|
rb.MoveToPrevWord()
|
||||||
case 'w', 'W', 'e', 'E':
|
case 'w', 'W':
|
||||||
rb.MoveToNextWord()
|
rb.MoveToNextWord()
|
||||||
|
case 'e', 'E':
|
||||||
|
rb.MoveToEndWord()
|
||||||
case 'f', 'F', 't', 'T':
|
case 'f', 'F', 't', 'T':
|
||||||
next := readNext()
|
next := readNext()
|
||||||
prevChar := r == 't' || r == 'T'
|
prevChar := r == 't' || r == 'T'
|
||||||
|
|
Loading…
Reference in New Issue