forked from qt-creator/qt-creator
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 <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:
@@ -1691,7 +1691,8 @@ void ClangdClient::findLocalUsages(TextDocument *document, const QTextCursor &cu
|
|||||||
<< link.targetLine << (link.targetColumn + 1);
|
<< link.targetLine << (link.targetColumn + 1);
|
||||||
if (!d->localRefsData || id != d->localRefsData->id)
|
if (!d->localRefsData || id != d->localRefsData->id)
|
||||||
return;
|
return;
|
||||||
if (!link.hasValidTarget()) {
|
if (!link.hasValidTarget() || !d->localRefsData->document
|
||||||
|
|| d->localRefsData->document->filePath() != link.targetFilePath) {
|
||||||
d->localRefsData.reset();
|
d->localRefsData.reset();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user