Add flush

This commit is contained in:
c-bata 2017-08-11 18:24:44 +09:00
parent aa686033e9
commit 4c3cbd3c3c
3 changed files with 3 additions and 5 deletions

View File

@ -22,6 +22,7 @@ func (c *CompletionManager) GetSelectedSuggestion() (s Suggest, ok bool) {
return Suggest{}, false
} else if c.selected < -1 {
log.Printf("[ERROR] shoud be reached here, selected=%d", c.selected)
c.selected = -1
return Suggest{}, false
}
return c.tmp[c.selected], true

View File

@ -1,9 +1,5 @@
package prompt
import (
"log"
)
const (
leftPrefix = " "
leftSuffix = " "
@ -98,7 +94,6 @@ func (r *Render) renderCompletion(buf *Buffer, completions *CompletionManager) {
suggestions,
int(r.col)-len(r.prefix),
)
log.Printf("[INFO] formatted: %#v\n", formatted)
l := len(formatted)
r.prepareArea(l)

View File

@ -12,6 +12,8 @@ type VT100Writer struct {
func (w *VT100Writer) WriteRaw(data []byte) {
w.buffer = append(w.buffer, data...)
// Flush because sometimes the render is broken when a large amount data in buffer.
w.Flush()
return
}