Clangd: do not modify the default replacement string

Fixes: QTCREATORBUG-28321
Fixes: QTCREATORBUG-28910
Change-Id: I4cfaf5ea3916a0ecbf0b0bae4d0c231513671c73
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io>
This commit is contained in:
David Schulz
2022-10-11 10:49:34 +02:00
parent 3c0c26f7b3
commit 4d688c932b
2 changed files with 4 additions and 3 deletions

View File

@@ -370,8 +370,6 @@ ClangdClient::ClangdClient(Project *project, const Utils::FilePath &jsonDbDir, c
setActivateDocumentAutomatically(true);
setCompletionAssistProvider(new ClangdCompletionAssistProvider(this));
setQuickFixAssistProvider(new ClangdQuickFixProvider(this));
symbolSupport().setDefaultRenamingSymbolMapper(
[](const QString &oldSymbol) { return oldSymbol + "_new"; });
symbolSupport().setLimitRenamingToProjects(true);
if (!project) {
QJsonObject initOptions;

View File

@@ -549,8 +549,11 @@ void SymbolSupport::handleRenameResponse(Core::SearchResult *search,
const std::optional<PrepareRenameRequest::Response::Error> &error = response.error();
QString errorMessage;
if (error.has_value()) {
m_client->log(*error);
errorMessage = error->toString();
if (errorMessage.contains("Cannot rename symbol: new name is the same as the old name"))
errorMessage = Tr::tr("Start typing to see replacements"); // clangd optimization
else
m_client->log(*error);
}
const std::optional<WorkspaceEdit> &edits = response.result();