diff --git a/src/plugins/qmljseditor/qmljsoutline.cpp b/src/plugins/qmljseditor/qmljsoutline.cpp index 41643e8da71..8d37863d6ef 100644 --- a/src/plugins/qmljseditor/qmljsoutline.cpp +++ b/src/plugins/qmljseditor/qmljsoutline.cpp @@ -10,6 +10,7 @@ #include #include #include +#include using namespace QmlJS; @@ -163,7 +164,6 @@ void QmlJSOutlineWidget::updateSelectionInText(const QItemSelection &selection) if (!syncCursor()) return; - if (!selection.indexes().isEmpty()) { QModelIndex index = selection.indexes().first(); QModelIndex sourceIndex = m_filterModel->mapToSource(index); @@ -173,6 +173,11 @@ void QmlJSOutlineWidget::updateSelectionInText(const QItemSelection &selection) if (!location.isValid()) return; + const QTextBlock lastBlock = m_editor->document()->lastBlock(); + const uint textLength = lastBlock.position() + lastBlock.length(); + if (location.offset >= textLength) + return; + Core::EditorManager *editorManager = Core::EditorManager::instance(); editorManager->cutForwardNavigationHistory(); editorManager->addCurrentPositionToNavigationHistory();