Skip to content

Commit

Permalink
fixup
Browse files Browse the repository at this point in the history
  • Loading branch information
ethanndickson committed Aug 12, 2024
1 parent 20f9762 commit f9ba2e9
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions command.go
Original file line number Diff line number Diff line change
Expand Up @@ -296,10 +296,16 @@ func copyFlagSetWithout(fs *pflag.FlagSet, without string) *pflag.FlagSet {
}

func (inv *Invocation) CurWords() (prev string, cur string) {
if len(inv.Args) == 1 {
switch len(inv.Args) {
// All the shells we support will supply at least one argument (empty string),
// but we don't want to panic.
case 0:
cur = ""
prev = ""
case 1:
cur = inv.Args[0]
prev = ""
} else {
default:
cur = inv.Args[len(inv.Args)-1]
prev = inv.Args[len(inv.Args)-2]
}
Expand Down

0 comments on commit f9ba2e9

Please sign in to comment.