fixes: flush chars if got io.EOF without '\n' (#58)

This commit is contained in:
chzyer 2016-06-19 23:06:37 +08:00 committed by GitHub
parent 03625fbce3
commit b411b0f4b2
1 changed files with 11 additions and 4 deletions

View File

@ -97,11 +97,18 @@ func (o *Operation) ioloop() {
keepInCompleteMode := false
r := o.t.ReadRune()
if r == 0 { // io.EOF
o.buf.Clean()
select {
case o.errchan <- io.EOF:
if o.buf.Len() == 0 {
o.buf.Clean()
select {
case o.errchan <- io.EOF:
}
break
} else {
// if stdin got io.EOF and there is something left in buffer,
// let's flush them by sending CharEnter.
// And we will got io.EOF int next loop.
r = CharEnter
}
break
}
isUpdateHistory := true