From ef638c3660683b8cf0aa04c5dbc72871a48ea40c Mon Sep 17 00:00:00 2001 From: David Schulz Date: Wed, 2 Apr 2025 08:04:36 +0200 Subject: [PATCH] Editor: fix gotoLine for non existing columns If TextEditorWidget::gotoLine is called with a column greater than the line length jump to the block end instead of stepping into the next line. Fixes: QTCREATORBUG-32592 Change-Id: I70f8ab09de92000ec228c27320671d12f8fa79e6 Reviewed-by: Christian Kandeler --- src/plugins/texteditor/texteditor.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/plugins/texteditor/texteditor.cpp b/src/plugins/texteditor/texteditor.cpp index 2560315ad70..fda0ad9c604 100644 --- a/src/plugins/texteditor/texteditor.cpp +++ b/src/plugins/texteditor/texteditor.cpp @@ -3493,7 +3493,9 @@ void TextEditorWidget::gotoLine(int line, int column, bool centerLine, bool anim const QTextBlock &block = document()->findBlockByNumber(blockNumber); if (block.isValid()) { QTextCursor cursor(block); - if (column > 0) { + if (column >= block.length()) { + cursor.movePosition(QTextCursor::EndOfBlock); + } else if (column > 0) { cursor.movePosition(QTextCursor::Right, QTextCursor::MoveAnchor, column); } else { int pos = cursor.position();