From 720d07928b956f68def5725e2a84e02b3ddb8dd7 Mon Sep 17 00:00:00 2001 From: Christian Kandeler Date: Tue, 20 Sep 2022 15:28:58 +0200 Subject: [PATCH] ClangCodeModel: Add missing check in findLocalUsages() 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: Icdcfd5583bf33346d8f0e3caf2751fd16f7d9602 Reviewed-by: Qt CI Bot Reviewed-by: Reviewed-by: David Schulz --- src/plugins/clangcodemodel/clangdclient.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/plugins/clangcodemodel/clangdclient.cpp b/src/plugins/clangcodemodel/clangdclient.cpp index 228126ef215..5cb961a673d 100644 --- a/src/plugins/clangcodemodel/clangdclient.cpp +++ b/src/plugins/clangcodemodel/clangdclient.cpp @@ -1691,7 +1691,8 @@ void ClangdClient::findLocalUsages(TextDocument *document, const QTextCursor &cu << link.targetLine << (link.targetColumn + 1); if (!d->localRefsData || id != d->localRefsData->id) return; - if (!link.hasValidTarget()) { + if (!link.hasValidTarget() || !d->localRefsData->document + || d->localRefsData->document->filePath() != link.targetFilePath) { d->localRefsData.reset(); return; }