fix: Applied go fmt, fixed masked output

Lines 489-491 in runebuf.go are repeated in lines 506-508.
This typo led to working cursor through prompt text.
Deleting repeated lines fix that issue.
Applied go fmt to runebuf.go

* Masked output error
* Fmt
This commit is contained in:
karantin2020 2019-03-12 06:27:08 +05:00
parent 2972be24d4
commit 28ceb3e833
1 changed files with 3 additions and 6 deletions

View File

@ -35,7 +35,7 @@ type RuneBuffer struct {
sync.Mutex sync.Mutex
} }
func (r* RuneBuffer) pushKill(text []rune) { func (r *RuneBuffer) pushKill(text []rune) {
r.lastKill = append([]rune{}, text...) r.lastKill = append([]rune{}, text...)
} }
@ -221,7 +221,7 @@ func (r *RuneBuffer) DeleteWord() {
} }
for i := init + 1; i < len(r.buf); i++ { for i := init + 1; i < len(r.buf); i++ {
if !IsWordBreak(r.buf[i]) && IsWordBreak(r.buf[i-1]) { 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.Refresh(func() {
r.buf = append(r.buf[:r.idx], r.buf[i-1:]...) r.buf = append(r.buf[:r.idx], r.buf[i-1:]...)
}) })
@ -350,7 +350,7 @@ func (r *RuneBuffer) Yank() {
return return
} }
r.Refresh(func() { 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.buf[:r.idx]...)
buf = append(buf, r.lastKill...) buf = append(buf, r.lastKill...)
buf = append(buf, r.buf[r.idx:]...) buf = append(buf, r.buf[r.idx:]...)
@ -486,9 +486,6 @@ func (r *RuneBuffer) output() []byte {
} else { } else {
buf.Write([]byte(string(r.cfg.MaskRune))) buf.Write([]byte(string(r.cfg.MaskRune)))
} }
if len(r.buf) > r.idx {
buf.Write(r.getBackspaceSequence())
}
} else { } else {
for _, e := range r.cfg.Painter.Paint(r.buf, r.idx) { for _, e := range r.cfg.Painter.Paint(r.buf, r.idx) {