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 <christian.kandeler@qt.io>
This commit is contained in:
David Schulz
2025-04-02 08:04:36 +02:00
parent ee97ea0359
commit ef638c3660

View File

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