TextEditor: Make sure cursor is visible after refactoring

Fixes: QTCREATORBUG-27210
Change-Id: I612f6e91188730d6abdfef3f2fe8a286fcec4831
Reviewed-by: David Schulz <david.schulz@qt.io>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
This commit is contained in:
Christian Kandeler
2022-03-21 14:08:13 +01:00
parent ff8d672fa2
commit a3e0b139de

View File

@@ -332,10 +332,13 @@ bool RefactoringFile::apply()
}
// open / activate / goto position
bool ensureCursorVisible = false;
if (m_openEditor && !m_filePath.isEmpty()) {
int line = -1, column = -1;
if (m_editorCursorPosition != -1)
if (m_editorCursorPosition != -1) {
lineAndColumn(m_editorCursorPosition, &line, &column);
ensureCursorVisible = true;
}
m_editor = RefactoringChanges::openEditor(m_filePath, m_activateEditor, line, column);
m_openEditor = false;
m_activateEditor = false;
@@ -396,6 +399,9 @@ bool RefactoringFile::apply()
}
}
if (m_editor && ensureCursorVisible)
m_editor->ensureCursorVisible();
m_appliedOnce = true;
return result;
}