summaryrefslogtreecommitdiff
path: root/gocomplete
diff options
context:
space:
mode:
Diffstat (limited to 'gocomplete')
-rw-r--r--gocomplete/complete.go8
-rw-r--r--gocomplete/tests.go15
2 files changed, 13 insertions, 10 deletions
diff --git a/gocomplete/complete.go b/gocomplete/complete.go
index 75d3672..1575e1b 100644
--- a/gocomplete/complete.go
+++ b/gocomplete/complete.go
@@ -6,9 +6,11 @@ import "github.com/posener/complete"
var (
predictEllipsis = complete.PredictSet("./...")
- goFilesOrPackages = complete.PredictFiles("*.go").
- Or(complete.PredictDirs("*")).
- Or(predictEllipsis)
+ goFilesOrPackages = complete.PredictOr(
+ complete.PredictFiles("*.go"),
+ complete.PredictDirs("*"),
+ predictEllipsis,
+ )
)
func main() {
diff --git a/gocomplete/tests.go b/gocomplete/tests.go
index 40210d4..d2c32e7 100644
--- a/gocomplete/tests.go
+++ b/gocomplete/tests.go
@@ -17,15 +17,16 @@ import (
// and then all the relevant function names.
// for test names use prefix of 'Test' or 'Example', and for benchmark
// test names use 'Benchmark'
-func predictTest(funcPrefix ...string) complete.Predicate {
- return func(last string) []match.Matcher {
+func predictTest(funcPrefix ...string) complete.Predictor {
+ return complete.PredictFunc(func(a complete.Args) (prediction []string) {
tests := testNames(funcPrefix)
- options := make([]match.Matcher, len(tests))
- for i := range tests {
- options[i] = match.Prefix(tests[i])
+ for _, t := range tests {
+ if match.Prefix(t, a.Last) {
+ prediction = append(prediction, t)
+ }
}
- return options
- }
+ return
+ })
}
// get all test names in current directory