Add completionOnDown option
This commit is contained in:
parent
df850582f4
commit
49fa645ffe
|
@ -206,6 +206,14 @@ func OptionSwitchKeyBindMode(m KeyBindMode) Option {
|
|||
}
|
||||
}
|
||||
|
||||
// OptionSwitchKeyBindMode set a key bind mode.
|
||||
func OptionCompletionOnDown() Option {
|
||||
return func(p *Prompt) error {
|
||||
p.completionOnDown = true
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
// SwitchKeyBindMode to set a key bind mode.
|
||||
// Deprecated: Please use OptionSwitchKeyBindMode.
|
||||
var SwitchKeyBindMode = OptionSwitchKeyBindMode
|
||||
|
|
|
@ -25,6 +25,7 @@ type Prompt struct {
|
|||
keyBindings []KeyBind
|
||||
ASCIICodeBindings []ASCIICodeBind
|
||||
keyBindMode KeyBindMode
|
||||
completionOnDown bool
|
||||
}
|
||||
|
||||
// Exec is the struct contains user input context.
|
||||
|
@ -126,7 +127,7 @@ func (p *Prompt) feed(b []byte) (shouldExit bool, exec *Exec) {
|
|||
if !completing { // Don't use p.completion.Completing() because it takes double operation when switch to selected=-1.
|
||||
if newBuf, changed := p.history.Newer(p.buf); changed {
|
||||
p.buf = newBuf
|
||||
} else {
|
||||
} else if p.completionOnDown {
|
||||
p.completion.Next()
|
||||
}
|
||||
return
|
||||
|
|
Loading…
Reference in New Issue