Skip to content

Commit 678303c

Browse files
authored
[clangd] Fix code action kind for readability-identifier-naming fixes (#162808)
#78454 converted readability-identifier-naming fixes to use rename mechanism to rename the symbol project-wide. However, it set the code action kind to "refactor" instead of "quickfix", which caused the fixes to be filtered out when editors (like VS Code) request quick fixes for diagnostics. On VS Code, for example, users would see "No quick fixes available" despite the diagnostic indicating "(fix available)". Fix that by changing the code action kind back to "quickfix". Signed-off-by: Ruoyu Zhong <[email protected]>
1 parent 982c9e6 commit 678303c

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

clang-tools-extra/clangd/ClangdLSPServer.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ CodeAction toCodeAction(const ClangdServer::CodeActionResult::Rename &R,
8181
const URIForFile &File) {
8282
CodeAction CA;
8383
CA.title = R.FixMessage;
84-
CA.kind = std::string(CodeAction::REFACTOR_KIND);
84+
CA.kind = std::string(CodeAction::QUICKFIX_KIND);
8585
CA.command.emplace();
8686
CA.command->title = R.FixMessage;
8787
CA.command->command = std::string(ApplyRenameCommand);

clang-tools-extra/clangd/unittests/ClangdLSPServerTests.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,8 @@ TEST_F(LSPTest, ClangTidyRename) {
235235
.takeValue()
236236
.getAsArray())[0];
237237

238-
ASSERT_EQ((*RenameCommand.getAsObject())["title"], "change 'foo' to 'Foo'");
238+
ASSERT_EQ((*RenameCommand.getAsObject())["title"],
239+
"Apply fix: change 'foo' to 'Foo'");
239240

240241
Client.expectServerCall("workspace/applyEdit");
241242
Client.call("workspace/executeCommand", RenameCommand);

0 commit comments

Comments
 (0)