Skip to content

Refactor preview doesn't show preview with clangd #161604

@hokein

Description

@hokein

Coming from clangd/vscode-clangd#376

  • VS Code Version: 1.71.2
  • OS Version: MacOS

Steps to Reproduce:

  1. opened a dummy t.cc (auto S = 1;) in VSCode with vscode-clangd extension, waiting for clangd to warm up.
  2. Move the cursor to auto, click the 💡 and get a CodeAction menu
  3. Move the cursor to the Expand auto type Code ACtion, and press Command + Enter

Expected result: a preview pane will be shown
Actual result: we apply the code action without showing the preview

A special bit about clangd which may be related: the CodeAction returned from clangd doesn't have the edit field propagated, instead we use the applyTweak command to apply a workspace edit.

The detailed logs in case it is useful:

V[] <<< {"id":9,"jsonrpc":"2.0","method":"textDocument/codeAction","params":{"context":{"diagnostics":[],"triggerKind":2},"range":{"end":{"character":2,"line":0},"start":{"character":2,"line":0}},"textDocument":{"uri":"file:///tmp/t3.cpp"}}}
I[] <-- textDocument/codeAction(9)
I[] --> reply:textDocument/codeAction(9) 0 ms
V[] >>> {"id":9,"jsonrpc":"2.0","result":[{"command":{"arguments":[{"file":"file:///tmp/t3.cpp","selection":{"end":{"character":2,"line":0},"start":{"character":2,"line":0}},"tweakID":"ExpandAutoType"}],"command":"clangd.applyTweak","title":"Expand auto type"},"kind":"refactor","title":"Expand auto type"}]}


V[] <<< {"id":10,"jsonrpc":"2.0","method":"workspace/executeCommand","params":{"arguments":[{"file":"file:///tmp/t3.cpp","selection":{"end":{"character":2,"line":0},"start":{"character":2,"line":0}},"tweakID":"ExpandAutoType"}],"command":"clangd.applyTweak"}}
I[] <-- workspace/executeCommand(10)
I[] --> workspace/applyEdit(1)
V[] >>> {"id":1,"jsonrpc":"2.0","method":"workspace/applyEdit","params":{"edit":{"changes":{"file:///tmp/t3.cpp":[{"newText":"int","range":{"end":{"character":4,"line":0},"start":{"character":0,"line":0}}},{"newText":"\n","range":{"end":{"character":0,"line":2},"start":{"character":11,"line":0}}}]}}}}

Metadata

Metadata

Assignees

Labels

*as-designedDescribed behavior is as designededitor-code-actionsEditor inplace actions (Ctrl + .)

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions