Skip to content

Commit 1ac2ca6

Browse files
committed
Fixed converting 'ignore ... for this line' Fix into rename bug
1 parent 19265f9 commit 1ac2ca6

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

clang-tools-extra/clangd/ClangdServer.cpp

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -701,14 +701,21 @@ void ClangdServer::codeAction(const CodeActionInputs &Params,
701701
return nullptr;
702702
};
703703
for (const auto &DiagRef : Params.Diagnostics) {
704-
if (const auto *Diag = FindMatchedDiag(DiagRef))
705-
for (const auto &Fix : Diag->Fixes) {
706-
if (auto Rename = tryConvertToRename(Diag, Fix)) {
704+
if (const auto *Diag = FindMatchedDiag(DiagRef)) {
705+
auto It = Diag->Fixes.begin();
706+
if (It != Diag->Fixes.end()) {
707+
if (auto Rename = tryConvertToRename(Diag, *It)) {
708+
// Only try to convert the first Fix to rename as subsequent Fixes
709+
// might be "ignore [readability-identifier-naming] for this
710+
// line".
707711
Result.Renames.emplace_back(std::move(*Rename));
708-
} else {
709-
Result.QuickFixes.push_back({DiagRef, Fix});
712+
It++;
710713
}
711714
}
715+
for (; It != Diag->Fixes.end(); It++) {
716+
Result.QuickFixes.push_back({DiagRef, *It});
717+
}
718+
}
712719
}
713720
}
714721

0 commit comments

Comments
 (0)