@@ -11,7 +11,7 @@ import (
1111 "io"
1212 "margo.sh/golang/internal/gocode"
1313 "margo.sh/mg"
14- "margo.sh/misc/pf "
14+ "margo.sh/mgpf "
1515 "margo.sh/sublime"
1616 "strings"
1717 "time"
@@ -71,7 +71,13 @@ func (g *Gocode) ReducerConfig(mx *mg.Ctx) mg.EditorConfig {
7171 return nil
7272 }
7373
74+ // ST might query the GoSublime plugin first, so we must always disable it
7475 cfg = cfg .DisableGsComplete ()
76+ // but we don't want to affect editor completions in non-go files
77+ if ! g .ReducerCond (mx ) {
78+ return cfg
79+ }
80+
7581 if ! g .AllowExplicitCompletions {
7682 cfg = cfg .InhibitExplicitCompletions ()
7783 }
@@ -82,7 +88,7 @@ func (g *Gocode) ReducerConfig(mx *mg.Ctx) mg.EditorConfig {
8288}
8389
8490func (g * Gocode ) ReducerCond (mx * mg.Ctx ) bool {
85- return mx .LangIs ( "go" ) && mx .ActionIs (mg.QueryCompletions {} )
91+ return mx .ActionIs (mg. QueryCompletions {} ) && mx .LangIs (mg .Go )
8692}
8793
8894func (g * Gocode ) ReducerMount (mx * mg.Ctx ) {
@@ -116,7 +122,7 @@ func (g *Gocode) Reduce(mx *mg.Ctx) *mg.State {
116122 select {
117123 case g .reqs <- gr :
118124 case <- time .After (qTimeout ):
119- mx .Log .Println ("gocode didn't accept the request after" , pf .D (time .Since (start )))
125+ mx .Log .Println ("gocode didn't accept the request after" , mgpf .D (time .Since (start )))
120126 return st
121127 }
122128
@@ -131,10 +137,10 @@ func (g *Gocode) Reduce(mx *mg.Ctx) *mg.State {
131137 case <- time .After (pTimeout ):
132138 go func () {
133139 <- gr .res
134- mx .Log .Println ("gocode eventually responded after" , pf .Since (start ))
140+ mx .Log .Println ("gocode eventually responded after" , mgpf .Since (start ))
135141 }()
136142
137- mx .Log .Println ("gocode didn't respond after" , pf .D (pTimeout ), "taking" , pf .Since (start ))
143+ mx .Log .Println ("gocode didn't respond after" , mgpf .D (pTimeout ), "taking" , mgpf .Since (start ))
138144 return st
139145 }
140146}
0 commit comments