diff --git a/src/plugins/qmljseditor/qmljsoutline.cpp b/src/plugins/qmljseditor/qmljsoutline.cpp index 41643e8da710ae0d14c192662c428abe23f4d98b..8d37863d6ef9e58b9dac7d361222af8c9333a795 100644 --- a/src/plugins/qmljseditor/qmljsoutline.cpp +++ b/src/plugins/qmljseditor/qmljsoutline.cpp @@ -10,6 +10,7 @@ #include <QtCore/QSettings> #include <QtGui/QAction> #include <QtGui/QVBoxLayout> +#include <QtGui/QTextBlock> 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();