Commit a943350b authored by mae's avatar mae
Browse files

Fixed cursor position in file when switching editors

When closing editor splits while the same document was visible in
two editors, it could happen that the state of the closed editor
survived (as opposed to sate of the editor which was still visible).
This had the negative effect, that when visiting the file again,
the cursor would jump to the obsolete position within the file.
parent 33b4b15a
......@@ -583,6 +583,24 @@ void EditorManager::closeView(Core::Internal::EditorView *view)
if (IEditor *e = view->currentEditor()) {
when we are closing a view with an original editor which has
duplicates, then make one of the duplicates the original.
Otherwise the original would be kept around and the user might
experience jumping to a missleading position within the file when
visiting the file again. With the code below, the position within
the file will be the position of the first duplicate which is still
if (!m_d->m_editorModel->isDuplicate(e)) {
QList<IEditor *> duplicates = m_d->m_editorModel->duplicatesFor(e);
if (!duplicates.isEmpty()) {
SplitterOrView *splitterOrView = m_d->m_splitter->findView(view);
......@@ -597,10 +615,11 @@ void EditorManager::closeView(Core::Internal::EditorView *view)
SplitterOrView *newCurrent = splitter->findFirstView();
if (newCurrent) {
if (newCurrent->editor())
activateEditor(newCurrent->view(), newCurrent->editor());
if (IEditor *e = newCurrent->editor()) {
activateEditor(newCurrent->view(), e);
} else {
Supports Markdown
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