TextEditor: Fallback to last line when input line exceeds the document

Task-number: QTCREATORBUG-14782
Change-Id: I7ead94a132207ccaae661cb6aceff5387d11b818
Reviewed-by: Robert Loehning <robert.loehning@theqtcompany.com>
Reviewed-by: Eike Ziller <eike.ziller@theqtcompany.com>
This commit is contained in:
Orgad Shaneh
2015-08-04 21:24:31 +03:00
committed by Orgad Shaneh
parent 93e0ffa942
commit 6c13ce05af

View File

@@ -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);