diff --git a/operation.go b/operation.go index 4c31624..c357f40 100644 --- a/operation.go +++ b/operation.go @@ -385,7 +385,7 @@ func (o *Operation) Runes() ([]rune, error) { listener.OnChange(nil, 0, 0) } - o.buf.Refresh(nil) // print prompt + o.buf.Print() // print prompt o.t.KickRead() select { case r := <-o.outchan: diff --git a/runebuf.go b/runebuf.go index 81d2da5..5b63955 100644 --- a/runebuf.go +++ b/runebuf.go @@ -471,6 +471,15 @@ func (r *RuneBuffer) SetOffset(offset string) { r.Unlock() } +func (r *RuneBuffer) Print() { + if !r.interactive { + return + } + r.Lock() + defer r.Unlock() + r.print() +} + func (r *RuneBuffer) print() { r.w.Write(r.output()) r.hadClean = false @@ -597,8 +606,9 @@ func (r *RuneBuffer) cleanOutput(w io.Writer, idxLine int) { } else { buf.Write([]byte("\033[J")) // just like ^k :) if idxLine == 0 { - buf.WriteString("\033[2K") - buf.WriteString("\r") + num := strconv.Itoa(r.idx + r.promptLen()) + buf.WriteString("\033[" + num + "D") + buf.Write([]byte("\033[J")) } else { for i := 0; i < idxLine; i++ { io.WriteString(buf, "\033[2K\r\033[A")