mirror of https://github.com/golang/go.git
internal/lsp: return all code action kinds with context.only prefix
When context.Only is passed in the codeAction request, all code actions that have a matching prefix should be returned. For example: context.Only: "refactor" want: "refactor.extract", "refactor.rewrite" Fixes golang/go#49263 Change-Id: I4bcea4a0b0097f3187f3d7055cbb73b518008107 Reviewed-on: https://go-review.googlesource.com/c/tools/+/361834 Trust: Suzy Mueller <suzmue@golang.org> Run-TryBot: Suzy Mueller <suzmue@golang.org> gopls-CI: kokoro <noreply+kokoro@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Robert Findley <rfindley@google.com>
This commit is contained in:
parent
fafc446eff
commit
5e46725290
|
|
@ -51,7 +51,12 @@ func (s *Server) codeAction(ctx context.Context, params *protocol.CodeActionPara
|
|||
} else {
|
||||
wanted = make(map[protocol.CodeActionKind]bool)
|
||||
for _, only := range params.Context.Only {
|
||||
wanted[only] = supportedCodeActions[only] || explicit[only]
|
||||
for k, v := range supportedCodeActions {
|
||||
if only == k || strings.HasPrefix(string(k), string(only)+".") {
|
||||
wanted[k] = wanted[k] || v
|
||||
}
|
||||
}
|
||||
wanted[only] = wanted[only] || explicit[only]
|
||||
}
|
||||
}
|
||||
if len(supportedCodeActions) == 0 {
|
||||
|
|
|
|||
Loading…
Reference in New Issue