update demo

This commit is contained in:
Cheney 2015-09-26 01:01:20 +08:00
parent d07044cdb6
commit 75bbfa6d42
3 changed files with 11 additions and 2 deletions

View File

@ -134,7 +134,9 @@ func (o *opCompleter) HandleCompleteSelect(r rune) bool {
} }
o.candicateChoise = tmpChoise o.candicateChoise = tmpChoise
case CharBackward: case CharBackward:
o.nextCandicate(-1) if o.op.buf.Len() > 0 {
o.nextCandicate(-1)
}
case CharPrev: case CharPrev:
tmpChoise := o.candicateChoise - o.candicateColNum tmpChoise := o.candicateChoise - o.candicateColNum
if tmpChoise < 0 { if tmpChoise < 0 {
@ -146,6 +148,7 @@ func (o *opCompleter) HandleCompleteSelect(r rune) bool {
o.candicateChoise = tmpChoise o.candicateChoise = tmpChoise
default: default:
next = false next = false
o.ExitCompleteSelectMode()
} }
if next { if next {
o.CompleteRefresh() o.CompleteRefresh()

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.0 MiB

After

Width:  |  Height:  |  Size: 1.8 MiB

View File

@ -66,7 +66,10 @@ func (o *Operation) ioloop() {
o.buf.Refresh() o.buf.Refresh()
switch r { switch r {
case CharInterrupt, CharEnter, CharCtrlJ: case CharEnter, CharCtrlJ:
o.UpdateHistory(o.buf.Runes(), false)
fallthrough
case CharInterrupt:
o.t.KickRead() o.t.KickRead()
fallthrough fallthrough
case CharCancel: case CharCancel:
@ -120,6 +123,9 @@ func (o *Operation) ioloop() {
break break
} }
if o.buf.Len() == 0 {
break
}
o.buf.Backspace() o.buf.Backspace()
if o.IsInCompleteMode() { if o.IsInCompleteMode() {
o.OnComplete() o.OnComplete()