forked from qt-creator/qt-creator
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 <qt_ci_bot@qt-project.org> Reviewed-by: <github-actions-qt-creator@cristianadam.eu> Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
Reference in New Issue
Block a user