aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/cppeditor/cppeditordocument.cpp
diff options
context:
space:
mode:
authorArtem Sokolovskii <artem.sokolovskii@qt.io>2022-06-03 15:10:46 +0200
committerArtem Sokolovskii <artem.sokolovskii@qt.io>2022-06-08 13:17:18 +0000
commit6d1478e1db134d37935b1c65adb226edf60e9f6e (patch)
tree271b2ed6dd0ca219e14cb246bd8ec249f07cf2ea /src/plugins/cppeditor/cppeditordocument.cpp
parent55cf108f96564304db9b1b4951b93f24279451d6 (diff)
Clang Format: Fix misplaced cursor after undo
Fixed behavior, when after undo function cursor, jumps to the start of a file. Join the undo block generated by auto format with the last available undo block. This will place the cursor at the last edit position instead of the document beginning when triggering undo. Fixes: QTCREATORBUG-27608 Change-Id: I1bb630af00e997ac53f178594445293ceebcfa26 Reviewed-by: <github-actions-qt-creator@cristianadam.eu> Reviewed-by: David Schulz <david.schulz@qt.io>
Diffstat (limited to 'src/plugins/cppeditor/cppeditordocument.cpp')
-rw-r--r--src/plugins/cppeditor/cppeditordocument.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/plugins/cppeditor/cppeditordocument.cpp b/src/plugins/cppeditor/cppeditordocument.cpp
index e79d8a1767..f821440126 100644
--- a/src/plugins/cppeditor/cppeditordocument.cpp
+++ b/src/plugins/cppeditor/cppeditordocument.cpp
@@ -487,7 +487,7 @@ bool CppEditorDocument::save(QString *errorString, const Utils::FilePath &filePa
if (!editedRanges.empty()) {
QTextCursor cursor(document());
- cursor.beginEditBlock();
+ cursor.joinPreviousEditBlock();
indenter()->format(editedRanges);
cursor.endEditBlock();
}