@@ -27,7 +27,7 @@ func ActionSymbols(opts SymbolOpts) carapace.Action {
2727 args = append (args , opts .Package )
2828 return carapace .ActionExecCommand ("go" , args ... )(func (output []byte ) carapace.Action {
2929 lines := strings .Split (string (output ), "\n " )
30- r := regexp .MustCompile (`^ *(?P<type>var|func|type|const) (?P<symbol>[^( =]+).*` ) // TODO incomplete (e.g. generics))
30+ r := regexp .MustCompile (`^ *(?P<type>var|func|type|const) (?P<symbol>[^( =\[ ]+).*` ) // TODO incomplete (e.g. generics))
3131
3232 variables := make ([]string , 0 )
3333 functions := make ([]string , 0 )
@@ -77,19 +77,20 @@ func ActionMethodOrFields(opts MethodOrFieldOpts) carapace.Action {
7777 args = append (args , opts .Package , opts .Symbol )
7878 return carapace .ActionExecCommand ("go" , args ... )(func (output []byte ) carapace.Action {
7979 lines := strings .Split (string (output ), "\n " )
80- r := regexp .MustCompile (fmt .Sprintf (`^func \([^ ]+ \*?%v\) (?P<method>[^( =]+).*` , opts .Symbol ))
80+ rFunc := regexp .MustCompile (fmt .Sprintf (`^func \([^ ]+ \*?%v(\[[^)]+)?\) (?P<method>[^( =]+).*` , opts .Symbol ))
81+ rType := regexp .MustCompile (fmt .Sprintf (`^type %v[\[ ].*\{$` , opts .Symbol ))
8182
8283 methods := make ([]string , 0 )
8384 for _ , line := range lines {
84- if matches := r .FindStringSubmatch (line ); matches != nil {
85- methods = append (methods , matches [1 ])
85+ if matches := rFunc .FindStringSubmatch (line ); matches != nil {
86+ methods = append (methods , matches [2 ])
8687 }
8788 }
8889
8990 found := false
9091 fields := make ([]string , 0 )
9192 for _ , line := range lines {
92- if strings . HasPrefix (line , fmt . Sprintf ( "type %v " , opts . Symbol )) && strings . HasSuffix ( line , "{" ) {
93+ if rType . MatchString (line ) {
9394 found = true
9495 continue
9596 }
0 commit comments