forked from qt-creator/qt-creator
CppEditor: improve quickfix after local renaming
Always update the local usages of the symbol under cursor even if we are currently renaming a local symbol. Otherwise the semantic info is classified as not up to date, which in turns limits the quick fix operation to the ones coming from clangd. As a next step we could make sure the semantic info is valid and up to date before creating the code assist interface by calling a synchronous CppUseSelectionsUpdater::update. But as this will potentially block the ui, it will require some extra handling. Change-Id: Icb9f523a5a21e65a2853e3b98a17c2f45c637825 Reviewed-by: Christian Kandeler <christian.kandeler@qt.io> Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
This commit is contained in:
@@ -478,7 +478,6 @@ void CppEditorWidget::finalizeInitialization()
|
||||
|
||||
// set up the use highlighitng
|
||||
connect(this, &CppEditorWidget::cursorPositionChanged, this, [this] {
|
||||
if (!d->m_localRenaming.isActive())
|
||||
d->m_useSelectionsUpdater.scheduleUpdate();
|
||||
|
||||
// Notify selection expander about the changed cursor.
|
||||
@@ -1223,12 +1222,10 @@ void CppEditorWidget::updateSemanticInfo(const SemanticInfo &semanticInfo,
|
||||
|
||||
d->m_lastSemanticInfo = semanticInfo;
|
||||
|
||||
if (!d->m_localRenaming.isActive()) {
|
||||
const CppUseSelectionsUpdater::CallType type = updateUseSelectionSynchronously
|
||||
? CppUseSelectionsUpdater::CallType::Synchronous
|
||||
const CppUseSelectionsUpdater::CallType type
|
||||
= updateUseSelectionSynchronously ? CppUseSelectionsUpdater::CallType::Synchronous
|
||||
: CppUseSelectionsUpdater::CallType::Asynchronous;
|
||||
d->m_useSelectionsUpdater.update(type);
|
||||
}
|
||||
|
||||
// schedule a check for a decl/def link
|
||||
updateFunctionDeclDefLink();
|
||||
|
@@ -52,7 +52,8 @@ CppUseSelectionsUpdater::RunnerInfo CppUseSelectionsUpdater::update(CallType cal
|
||||
auto *cppEditorDocument = qobject_cast<CppEditorDocument *>(cppEditorWidget->textDocument());
|
||||
QTC_ASSERT(cppEditorDocument, return RunnerInfo::FailedToStart);
|
||||
|
||||
m_updateSelections = !CppModelManager::usesClangd(cppEditorDocument);
|
||||
m_updateSelections = !CppModelManager::usesClangd(cppEditorDocument)
|
||||
&& !m_editorWidget->isRenaming();
|
||||
|
||||
CursorInfoParams params;
|
||||
params.semanticInfo = cppEditorWidget->semanticInfo();
|
||||
@@ -138,10 +139,6 @@ void CppUseSelectionsUpdater::onFindUsesFinished()
|
||||
emit finished(SemanticInfo::LocalUseMap(), false);
|
||||
return;
|
||||
}
|
||||
if (m_editorWidget->isRenaming()) {
|
||||
emit finished({}, false);
|
||||
return;
|
||||
}
|
||||
|
||||
processResults(m_runnerWatcher->result());
|
||||
|
||||
|
Reference in New Issue
Block a user