forked from qt-creator/qt-creator
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
This commit is contained in:
@@ -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)
|
||||
|
Reference in New Issue
Block a user