From d696f3380cb7191b2b6239894b9c6c4b4a0fc043 Mon Sep 17 00:00:00 2001 From: Christian Kandeler Date: Tue, 20 Sep 2022 15:39:34 +0200 Subject: [PATCH] ClangCodeModel: Add missing check in ClangdFindLocalReferences When trying to find out whether a symbol refers to a local variable, we first look up its definition. Afterwards, we need to check whether that definition is located in the same file. This was forgotten, which lead to seemingly random weirdness when trying to rename non-local symbols. Change-Id: I505675a784fc69dc4f01105033608116fc7720c2 Reviewed-by: Qt CI Bot Reviewed-by: Reviewed-by: David Schulz --- src/plugins/clangcodemodel/clangdfindreferences.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/plugins/clangcodemodel/clangdfindreferences.cpp b/src/plugins/clangcodemodel/clangdfindreferences.cpp index 597a0d0e159..6a709ff8386 100644 --- a/src/plugins/clangcodemodel/clangdfindreferences.cpp +++ b/src/plugins/clangcodemodel/clangdfindreferences.cpp @@ -494,7 +494,8 @@ void ClangdFindLocalReferences::Private::getDefinitionAst(const Link &link) qCDebug(clangdLog) << "received go to definition response" << link.targetFilePath << link.targetLine << (link.targetColumn + 1); - if (!link.hasValidTarget() || !document) { + if (!link.hasValidTarget() || !document + || link.targetFilePath.canonicalPath() != document->filePath().canonicalPath()) { finish(); return; }