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 {
591
591
func (inv * Invocation ) complete () []string {
592
592
prev , cur := inv .CurWords ()
593
593
594
+ // If the current word is a flag
594
595
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 {
599
600
if out := inv .completeFlag (flagName ); out != nil {
600
601
for i , o := range out {
601
602
out [i ] = fmt .Sprintf ("--%s=%s" , flagName , o )
602
603
}
603
604
return out
604
605
}
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
607
608
// shell moves the cursor
608
609
return []string {cur }
609
610
}
You can’t perform that action at this time.
0 commit comments