reinstate --initial-filter

This commit is contained in:
Daisuke Maki 2016-06-18 17:08:04 +09:00
parent 8c400c1d81
commit e1e64b83dc
2 changed files with 14 additions and 1 deletions

View file

@ -68,7 +68,8 @@ type Peco struct {
filters FilterSet
keymap Keymap
enableSep bool // Enable parsing on separators
initialQuery string // True if --query is specified
initialFilter string // populated if --initial-filter is specified
initialQuery string // populated if --query is specified
inputseq Inputseq // current key sequence (just the names)
layoutType string
location Location

12
peco.go
View file

@ -446,6 +446,18 @@ func (p *Peco) ApplyConfig(opts CLIOptions) error {
return errors.Wrap(err, "failed to populate styles")
}
if len(opts.OptInitialFilter) <= 0 && len(opts.OptInitialMatcher) > 0 {
p.initialFilter = opts.OptInitialMatcher
} else if len(opts.OptInitialFilter) > 0 {
p.initialFilter = opts.OptInitialFilter
}
if v := p.initialFilter; v != "" {
if err := p.filters.SetCurrentByName(v); err != nil {
return errors.Wrap(err, "failed to set filter")
}
}
return nil
}