Commit 72b78c22 authored by Thorbjørn Lindeijer's avatar Thorbjørn Lindeijer
Browse files

Maintain the right cursor when undoing "clean whitespace" after saving

Previously it would always jump to the start of the document, since
that's where the newly created text cursor is at the beginEditBlock
call. Avoid this when saving the current editor by starting with the
cursor of the editor.

Reviewed-by: mae
Task-number: QTCREATORBUG-1807
parent 60bf6410
......@@ -162,7 +162,16 @@ bool BaseTextDocument::save(const QString &fileName)
{
QTextCursor cursor(m_document);
// When saving the current editor, make sure to maintain the cursor position for undo
Core::IEditor *currentEditor = Core::EditorManager::instance()->currentEditor();
if (BaseTextEditorEditable *editable = qobject_cast<BaseTextEditorEditable*>(currentEditor)) {
if (editable->file() == this)
cursor = editable->editor()->textCursor();
}
cursor.beginEditBlock();
cursor.movePosition(QTextCursor::Start);
if (m_storageSettings.m_cleanWhitespace)
cleanWhitespace(cursor, m_storageSettings.m_cleanIndentation, m_storageSettings.m_inEntireDocument);
if (m_storageSettings.m_addFinalNewLine)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment