Commit 9caecbae authored by Kai Koehne's avatar Kai Koehne
Browse files

QmlOutline: Prevent warnings about invalid offset for 'setPosition'

Check in advance whether position is still valid. This can be false if
the text has already changed, but the outline hasn't been yet updated.
parent b8f6156b
......@@ -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();
......
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