summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--predict_files.go32
1 files changed, 12 insertions, 20 deletions
diff --git a/predict_files.go b/predict_files.go
index 4b8c84a..c8adf7e 100644
--- a/predict_files.go
+++ b/predict_files.go
@@ -30,29 +30,21 @@ func files(pattern string, allowFiles bool) PredictFunc {
// if only one directory has matched the result, search recursively into
// this directory to give more results.
return func(a Args) (prediction []string) {
- for {
+ prediction = predictFiles(a, pattern, allowFiles)
- prediction = predictFiles(a, pattern, allowFiles)
-
- // if the number of prediction is not 1, we either have many results or
- // have no results, so we return it.
- if len(prediction) != 1 {
- return
- }
-
- // if the result is only one item, we might want to recursively check
- // for more accurate results.
- if prediction[0] == a.Last {
- return
- }
-
- // only try deeper, if the one item is a directory
- if stat, err := os.Stat(prediction[0]); err != nil || !stat.IsDir() {
- return
- }
+ // if the number of prediction is not 1, we either have many results or
+ // have no results, so we return it.
+ if len(prediction) != 1 {
+ return
+ }
- a.Last = prediction[0]
+ // only try deeper, if the one item is a directory
+ if stat, err := os.Stat(prediction[0]); err != nil || !stat.IsDir() {
+ return
}
+
+ a.Last = prediction[0]
+ return predictFiles(a, pattern, allowFiles)
}
}