Don't complete when last argument is previous directory

This commit is contained in:
Eyal Posener 2017-05-11 21:05:52 +03:00
parent d3bbb859d5
commit 7b1b902128
1 changed files with 4 additions and 0 deletions

View File

@ -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))