Skip to content

Commit

Permalink
fixed backescape the first word in buffer
Browse files Browse the repository at this point in the history
  • Loading branch information
Pavel Vorobyov committed Nov 6, 2018
1 parent 2972be2 commit 7637116
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions runebuf.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ type RuneBuffer struct {
sync.Mutex
}

func (r* RuneBuffer) pushKill(text []rune) {
func (r *RuneBuffer) pushKill(text []rune) {
r.lastKill = append([]rune{}, text...)
}

Expand Down Expand Up @@ -221,7 +221,7 @@ func (r *RuneBuffer) DeleteWord() {
}
for i := init + 1; i < len(r.buf); i++ {
if !IsWordBreak(r.buf[i]) && IsWordBreak(r.buf[i-1]) {
r.pushKill(r.buf[r.idx:i-1])
r.pushKill(r.buf[r.idx : i-1])
r.Refresh(func() {
r.buf = append(r.buf[:r.idx], r.buf[i-1:]...)
})
Expand Down Expand Up @@ -331,8 +331,8 @@ func (r *RuneBuffer) BackEscapeWord() {
if r.idx == 0 {
return
}
for i := r.idx - 1; i > 0; i-- {
if !IsWordBreak(r.buf[i]) && IsWordBreak(r.buf[i-1]) {
for i := r.idx - 1; i >= 0; i-- {
if !IsWordBreak(r.buf[i]) && (i == 0 || IsWordBreak(r.buf[i-1])) {
r.pushKill(r.buf[i:r.idx])
r.buf = append(r.buf[:i], r.buf[r.idx:]...)
r.idx = i
Expand All @@ -350,7 +350,7 @@ func (r *RuneBuffer) Yank() {
return
}
r.Refresh(func() {
buf := make([]rune, 0, len(r.buf) + len(r.lastKill))
buf := make([]rune, 0, len(r.buf)+len(r.lastKill))
buf = append(buf, r.buf[:r.idx]...)
buf = append(buf, r.lastKill...)
buf = append(buf, r.buf[r.idx:]...)
Expand Down

0 comments on commit 7637116

Please sign in to comment.