fix: dont complete binaries in path if complete req starts with file prefix

windows-fixes
TorchedSammy 2022-03-05 08:58:12 -04:00
parent 88fd6f01b9
commit 59963add14
Signed by: sammyette
GPG Key ID: 904FC49417B44DCD
1 changed files with 15 additions and 10 deletions

5
rl.go
View File

@ -60,6 +60,9 @@ func newLineReader(prompt string) *lineReader {
ctx = aliases.Resolve(ctx) ctx = aliases.Resolve(ctx)
if len(fields) == 1 { if len(fields) == 1 {
prefixes := []string{"./", "../", "/", "~/"}
for _, prefix := range prefixes {
if strings.HasPrefix(query, prefix) {
fileCompletions := fileComplete(query, ctx, fields) fileCompletions := fileComplete(query, ctx, fields)
if len(fileCompletions) != 0 { if len(fileCompletions) != 0 {
for _, f := range fileCompletions { for _, f := range fileCompletions {
@ -70,8 +73,10 @@ func newLineReader(prompt string) *lineReader {
completions = append(completions, f) completions = append(completions, f)
} }
compGroup[0].Suggestions = completions compGroup[0].Suggestions = completions
}
return "", compGroup return "", compGroup
} }
}
// filter out executables, but in path // filter out executables, but in path
for _, dir := range filepath.SplitList(os.Getenv("PATH")) { for _, dir := range filepath.SplitList(os.Getenv("PATH")) {