diff options
| author | Eyal Posener <[email protected]> | 2017-05-11 20:48:40 +0300 |
|---|---|---|
| committer | Eyal Posener <[email protected]> | 2017-05-11 20:48:40 +0300 |
| commit | 115e175c3d254b3a4797607821a0aab6f08058bb (patch) | |
| tree | 81a786eb45eef5c59f02bb8f731efaa1f926f97b /predict.go | |
| parent | 967bae76f3132c210e6275653f9b603593973858 (diff) | |
Change Match to be a function
Diffstat (limited to 'predict.go')
| -rw-r--r-- | predict.go | 16 |
1 files changed, 6 insertions, 10 deletions
@@ -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 |
