From 7b1b902128e784fdf6ddeeb2347417f091fc8dc5 Mon Sep 17 00:00:00 2001 From: Eyal Posener Date: Thu, 11 May 2017 21:05:52 +0300 Subject: [PATCH] Don't complete when last argument is previous directory --- predict.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/predict.go b/predict.go index 9e1cce9..1db33f5 100644 --- a/predict.go +++ b/predict.go @@ -3,6 +3,7 @@ package complete import ( "os" "path/filepath" + "strings" "github.com/posener/complete/match" ) @@ -85,6 +86,9 @@ func PredictFilesOrDirs(pattern string) Predictor { func files(pattern string, allowDirs, allowFiles bool) PredictFunc { return func(a Args) (prediction []string) { + if strings.HasSuffix(a.Last, "/..") { + return + } dir := dirFromLast(a.Last) Log("looking for files in %s (last=%s)", dir, a.Last) files, err := filepath.Glob(filepath.Join(dir, pattern))