File tree Expand file tree Collapse file tree 1 file changed +7
-6
lines changed Expand file tree Collapse file tree 1 file changed +7
-6
lines changed Original file line number Diff line number Diff line change @@ -591,19 +591,20 @@ func (inv *Invocation) with(fn func(*Invocation)) *Invocation {
591591func (inv * Invocation ) complete () []string {
592592 prev , cur := inv .CurWords ()
593593
594+ // If the current word is a flag
594595 if strings .HasPrefix (cur , "--" ) {
595- // If the current word is a flag set using `=`, use it's handler
596- if strings . Contains ( cur , "=" ) {
597- words := strings . Split ( cur , "=" )
598- flagName := words [ 0 ][ 2 :]
596+ flagParts := strings . Split ( cur , "=" )
597+ flagName := flagParts [ 0 ][ 2 :]
598+ // If it's an equals flag
599+ if len ( flagParts ) == 2 {
599600 if out := inv .completeFlag (flagName ); out != nil {
600601 for i , o := range out {
601602 out [i ] = fmt .Sprintf ("--%s=%s" , flagName , o )
602603 }
603604 return out
604605 }
605- } else if out := inv .Command .Options .ByFlag (cur [ 2 :] ); out != nil {
606- // If the current word is a complete flag, auto-complete it so the
606+ } else if out := inv .Command .Options .ByFlag (flagName ); out != nil {
607+ // If the current word is a valid flag, auto-complete it so the
607608 // shell moves the cursor
608609 return []string {cur }
609610 }
You can’t perform that action at this time.
0 commit comments