summaryrefslogtreecommitdiff
path: root/predict.go
diff options
context:
space:
mode:
authorEyal Posener <[email protected]>2017-05-11 20:48:40 +0300
committerEyal Posener <[email protected]>2017-05-11 20:48:40 +0300
commit115e175c3d254b3a4797607821a0aab6f08058bb (patch)
tree81a786eb45eef5c59f02bb8f731efaa1f926f97b /predict.go
parent967bae76f3132c210e6275653f9b603593973858 (diff)
Change Match to be a function
Diffstat (limited to 'predict.go')
-rw-r--r--predict.go16
1 files changed, 6 insertions, 10 deletions
diff --git a/predict.go b/predict.go
index d5287c9..9e1cce9 100644
--- a/predict.go
+++ b/predict.go
@@ -49,19 +49,15 @@ var PredictAnything = PredictFunc(func(Args) []string { return nil })
// PredictSet expects specific set of terms, given in the options argument.
func PredictSet(options ...string) Predictor {
- p := predictSet{}
- for _, o := range options {
- p = append(p, match.Prefix(o))
- }
- return p
+ return predictSet(options)
}
-type predictSet []match.Prefix
+type predictSet []string
func (p predictSet) Predict(a Args) (prediction []string) {
for _, m := range p {
- if m.Match(a.Last) {
- prediction = append(prediction, m.String())
+ if match.Prefix(m, a.Last) {
+ prediction = append(prediction, m)
}
}
return
@@ -104,8 +100,8 @@ func files(pattern string, allowDirs, allowFiles bool) PredictFunc {
}
// add all matching files to prediction
for _, f := range files {
- if m := match.File(f); m.Match(a.Last) {
- prediction = append(prediction, m.String())
+ if match.File(f, a.Last) {
+ prediction = append(prediction, f)
}
}
return