From 6c13ce05afd92e0ceef19e005b2b22ebdf445b7a Mon Sep 17 00:00:00 2001 From: Orgad Shaneh Date: Tue, 4 Aug 2015 21:24:31 +0300 Subject: [PATCH] TextEditor: Fallback to last line when input line exceeds the document Task-number: QTCREATORBUG-14782 Change-Id: I7ead94a132207ccaae661cb6aceff5387d11b818 Reviewed-by: Robert Loehning Reviewed-by: Eike Ziller --- src/plugins/texteditor/texteditor.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugins/texteditor/texteditor.cpp b/src/plugins/texteditor/texteditor.cpp index b7f5302fef9..9238e2aa627 100644 --- a/src/plugins/texteditor/texteditor.cpp +++ b/src/plugins/texteditor/texteditor.cpp @@ -2513,7 +2513,7 @@ void TextEditorWidget::doSetTextCursor(const QTextCursor &cursor) void TextEditorWidget::gotoLine(int line, int column, bool centerLine) { d->m_lastCursorChangeWasInteresting = false; // avoid adding the previous position to history - const int blockNumber = line - 1; + const int blockNumber = qMin(line, document()->blockCount()) - 1; const QTextBlock &block = document()->findBlockByNumber(blockNumber); if (block.isValid()) { QTextCursor cursor(block);