Commit f30627b4 authored by mae's avatar mae
Browse files

Make persistent code folding and auto-collapse of the license header work together

parent 9ccd2f15
...@@ -1282,8 +1282,7 @@ void EditorManager::restoreEditorState(IEditor *editor) ...@@ -1282,8 +1282,7 @@ void EditorManager::restoreEditorState(IEditor *editor)
{ {
QTC_ASSERT(editor, return); QTC_ASSERT(editor, return);
QString fileName = editor->file()->fileName(); QString fileName = editor->file()->fileName();
if (m_d->m_editorStates.contains(fileName)) editor->restoreState(m_d->m_editorStates.value(fileName).toByteArray());
editor->restoreState(m_d->m_editorStates.value(fileName).toByteArray());
} }
bool EditorManager::saveEditor(IEditor *editor) bool EditorManager::saveEditor(IEditor *editor)
......
...@@ -609,8 +609,6 @@ bool BaseTextEditor::open(const QString &fileName) ...@@ -609,8 +609,6 @@ bool BaseTextEditor::open(const QString &fileName)
{ {
if (d->m_document->open(fileName)) { if (d->m_document->open(fileName)) {
moveCursor(QTextCursor::Start); moveCursor(QTextCursor::Start);
if (d->m_displaySettings.m_autoFoldFirstComment)
d->collapseLicenseHeader();
setReadOnly(d->m_document->hasDecodingError()); setReadOnly(d->m_document->hasDecodingError());
return true; return true;
} }
...@@ -1531,8 +1529,6 @@ void BaseTextEditor::memorizeCursorPosition() ...@@ -1531,8 +1529,6 @@ void BaseTextEditor::memorizeCursorPosition()
void BaseTextEditor::restoreCursorPosition() void BaseTextEditor::restoreCursorPosition()
{ {
restoreState(d->m_tempState); restoreState(d->m_tempState);
if (d->m_displaySettings.m_autoFoldFirstComment)
d->collapseLicenseHeader();
} }
QByteArray BaseTextEditor::saveState() const QByteArray BaseTextEditor::saveState() const
...@@ -1567,6 +1563,11 @@ QByteArray BaseTextEditor::saveState() const ...@@ -1567,6 +1563,11 @@ QByteArray BaseTextEditor::saveState() const
bool BaseTextEditor::restoreState(const QByteArray &state) bool BaseTextEditor::restoreState(const QByteArray &state)
{ {
if (state.isEmpty()) {
if (d->m_displaySettings.m_autoFoldFirstComment)
d->collapseLicenseHeader();
return false;
}
int version; int version;
int vval; int vval;
int hval; int hval;
...@@ -1588,6 +1589,9 @@ bool BaseTextEditor::restoreState(const QByteArray &state) ...@@ -1588,6 +1589,9 @@ bool BaseTextEditor::restoreState(const QByteArray &state)
if (block.isValid()) if (block.isValid())
TextBlockUserData::doCollapse(block, false); TextBlockUserData::doCollapse(block, false);
} }
} else {
if (d->m_displaySettings.m_autoFoldFirstComment)
d->collapseLicenseHeader();
} }
d->m_lastCursorChangeWasInteresting = false; // avoid adding last position to history d->m_lastCursorChangeWasInteresting = false; // avoid adding last position to history
......
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