forked from qt-creator/qt-creator
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:
committed by
Orgad Shaneh
parent
93e0ffa942
commit
6c13ce05af
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user