diff options
author | Christian Kandeler <christian.kandeler@qt.io> | 2024-01-23 10:03:45 +0100 |
---|---|---|
committer | Christian Kandeler <christian.kandeler@qt.io> | 2024-01-24 09:38:13 +0000 |
commit | f40c18784ba3e7ffc651afc81b9e6b246b5c1fb1 (patch) | |
tree | 400c2119b71c096e5ff7b5f13383337b22fff63b /src/plugins/texteditor/refactoringchanges.h | |
parent | 3df75b674051c31b5b6799662e3b151e0ae1716f (diff) |
TextEditor: Fix quickfix formatting
... for e.g. function insertion. In some contexts, the insertion
position is on the last line of some unrelated code (e.g. a preceding
function implementation) and the inserted code starts with a newline. In
that case, advance the position of the formatting cursor, so that we do
not accidentally format the existing code.
Fixes: QTCREATORBUG-30229
Change-Id: Id0be7f22e1797affa0602bb1d392a5e0802cbdcd
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: David Schulz <david.schulz@qt.io>
Diffstat (limited to 'src/plugins/texteditor/refactoringchanges.h')
-rw-r--r-- | src/plugins/texteditor/refactoringchanges.h | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/src/plugins/texteditor/refactoringchanges.h b/src/plugins/texteditor/refactoringchanges.h index c7fd87f675..913c731df2 100644 --- a/src/plugins/texteditor/refactoringchanges.h +++ b/src/plugins/texteditor/refactoringchanges.h @@ -16,6 +16,8 @@ #include <QSharedPointer> #include <QString> +#include <utility> + QT_BEGIN_NAMESPACE class QTextDocument; QT_END_NAMESPACE @@ -85,7 +87,10 @@ private: mutable QTextDocument *m_document = nullptr; TextEditorWidget *m_editor = nullptr; Utils::ChangeSet m_changes; - QList<QTextCursor> m_formattingCursors; + + // The bool indicates whether to advance the start position. + QList<std::pair<QTextCursor, bool>> m_formattingCursors; + bool m_openEditor = false; bool m_activateEditor = false; int m_editorCursorPosition = -1; |