diff --git a/complete.go b/complete.go index 262722b..8985b35 100644 --- a/complete.go +++ b/complete.go @@ -134,7 +134,9 @@ func (o *opCompleter) HandleCompleteSelect(r rune) bool { } o.candicateChoise = tmpChoise case CharBackward: - o.nextCandicate(-1) + if o.op.buf.Len() > 0 { + o.nextCandicate(-1) + } case CharPrev: tmpChoise := o.candicateChoise - o.candicateColNum if tmpChoise < 0 { @@ -146,6 +148,7 @@ func (o *opCompleter) HandleCompleteSelect(r rune) bool { o.candicateChoise = tmpChoise default: next = false + o.ExitCompleteSelectMode() } if next { o.CompleteRefresh() diff --git a/example/demo.gif b/example/demo.gif index c26c2e0..0a2c231 100644 Binary files a/example/demo.gif and b/example/demo.gif differ diff --git a/operation.go b/operation.go index 398f7ac..8d2622d 100644 --- a/operation.go +++ b/operation.go @@ -66,7 +66,10 @@ func (o *Operation) ioloop() { o.buf.Refresh() switch r { - case CharInterrupt, CharEnter, CharCtrlJ: + case CharEnter, CharCtrlJ: + o.UpdateHistory(o.buf.Runes(), false) + fallthrough + case CharInterrupt: o.t.KickRead() fallthrough case CharCancel: @@ -120,6 +123,9 @@ func (o *Operation) ioloop() { break } + if o.buf.Len() == 0 { + break + } o.buf.Backspace() if o.IsInCompleteMode() { o.OnComplete()