Merge pull request #141 from VonC/arrow
Down Arrow for first completion
This commit is contained in:
commit
b662637d18
|
@ -206,6 +206,14 @@ func OptionSwitchKeyBindMode(m KeyBindMode) Option {
|
|||
}
|
||||
}
|
||||
|
||||
// OptionCompletionOnDown allows for Down arrow key to trigger completion.
|
||||
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.
|
||||
|
@ -148,7 +149,7 @@ func (p *Prompt) feed(b []byte) (shouldExit bool, exec *Exec) {
|
|||
func (p *Prompt) handleCompletionKeyBinding(key Key, completing bool) {
|
||||
switch key {
|
||||
case Down:
|
||||
if completing {
|
||||
if completing || p.completionOnDown {
|
||||
p.completion.Next()
|
||||
}
|
||||
case Tab, ControlI:
|
||||
|
|
Loading…
Reference in New Issue