Skip to content
This repository has been archived by the owner on Oct 28, 2022. It is now read-only.

Search #16

Merged
merged 2 commits into from
May 11, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 18 additions & 1 deletion cmd/path.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,24 @@ var pathCmd = &cobra.Command{
Stdout: os.Stdout,
HideSelected: true,
Searcher: func(input string, index int) bool {
return strings.Contains(paths[index], input)
kws := strings.Split(input, " ")
result := true
count := 0
for _, kw := range kws {
if strings.HasPrefix(kw, "!") {
kw = strings.TrimLeft(kw, "!")
if kw == "" {
continue
}
result = result && !strings.Contains(paths[index], kw)
} else {
result = result && strings.Contains(paths[index], kw)
}
}
if result {
count++
}
return result
},
Keys: &promptui.SelectKeys{
Prev: promptui.Key{Code: promptui.KeyPrev, Display: promptui.KeyPrevDisplay},
Expand Down