Skip to content

x/tools/gopls: 'refactor'-only codeAction should return all available 'refactor.*' code action items #44213

@hyangah

Description

@hyangah

gopls version v0.6.5

When vscode user selects 'Refactor...' context menu entry, vscode requests codeAction with "context": { ... "only": ["refactor"]}. Gopls doesn't return anything even though there are possible refactoring actions applicable to the selected range.

[Trace - 14:38:03.583 PM] Sending request 'textDocument/codeAction - (10)'.
Params: {
  "textDocument":{"uri":"file:///Users/hakim/projects/w/main.go"},
  "range":{"start":{"line":6,"character":0},"end":{"line":8,"character":3}},
  "context":{"diagnostics":[],"only":["refactor"]}}


[Trace - 14:38:03.584 PM] Received response 'textDocument/codeAction - (10)' in 1ms.
Result: null

Compare against the result for the previous codeAction request on the same range:

[Trace - 14:37:57.484 PM] Sending request 'textDocument/codeAction - (8)'.
Params: {
   "textDocument":{"uri":"file:///Users/hakim/projects/w/main.go"},
   "range":{"start":{"line":6,"character":0},"end":{"line":8,"character":3}},
   "context":{"diagnostics":[]}}


[Trace - 14:37:57.485 PM] Received response 'textDocument/codeAction - (8)' in 0ms.
Result: [{
   "title":"Extract to function",
   "kind":"refactor.extract","edit":{},
   "command":{"title":"","command":"gopls.extract_function","arguments":["file:///Users/hakim/projects/w/main.go",{"start":{"line":6,"character":0},"end":{"line":8,"character":3}}]}}]

Metadata

Metadata

Assignees

No one assigned

    Labels

    FrozenDueToAgeToolsThis label describes issues relating to any tools in the x/tools repository.goplsIssues related to the Go language server, gopls.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions