Skip to content

Commit

Permalink
fish: nospace
Browse files Browse the repository at this point in the history
  • Loading branch information
rsteube committed Mar 30, 2023
1 parent 756c7ce commit 4f32ab8
Showing 1 changed file with 2 additions and 11 deletions.
13 changes: 2 additions & 11 deletions pkg/actions/bridge/fish.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ func ActionFish(command ...string) carapace.Action {
carapace.LOG.Println(snippet)
return carapace.ActionExecCommand("fish", "--command", snippet)(func(output []byte) carapace.Action {
lines := strings.Split(string(output), "\n")
nospace := false

vals := make([]string, 0)
for _, line := range lines[:len(lines)-1] {
Expand All @@ -49,21 +48,13 @@ func ActionFish(command ...string) carapace.Action {
} else {
vals = append(vals, splitted[0], "")
}
if value := splitted[0]; !nospace && len(value) > 0 && strings.ContainsAny(value[len(value)-1:], `/=@:.,-`) {
nospace = true
}

}
a := carapace.ActionValuesDescribed(vals...).StyleF(func(s string, sc style.Context) string {
return carapace.ActionValuesDescribed(vals...).StyleF(func(s string, sc style.Context) string {
if strings.HasPrefix(s, "--") && strings.Contains(s, "=") {
s = strings.SplitN(s, "=", 2)[1] // assume optarg
}
return style.ForPath(s, sc)
})
if nospace {
a = a.NoSpace()
}
return a
}).Invoke(c).ToA()
}).Invoke(c).ToA().NoSpace([]rune("/=@:.,")...)
})
}

0 comments on commit 4f32ab8

Please sign in to comment.