-
Bug
-
Resolution: Fixed
-
Not Evaluated
-
Qt Creator 18.0.0 (18.0 branch)
-
None
-
f263bec10 (master)
When navigating with up/down arrow keys through lines of different lengths, the cursor no longer remembers its original horizontal position. In version 17.0, when you move the cursor up or down to a shorter line and then continue to a longer line, the cursor returns to its original column position. In master, this position memory is lost and the cursor stays at the end of shorter lines.
The regression was introduced in commit 3e6ad023cc7 ("Editor: use one layout per editor instead of per document"). This commit added a new TextEditorLayout class with a custom moveCursorImpl method that handles cursor movement for the new per-editor layout system.
The issue is in TextEditorLayout::moveCursor() and moveCursorImpl() (src/libs/utils/plaintextedit/texteditorlayout.cpp). When the keyboard handler processes arrow keys (widgettextcontrol.cpp:401), it enables visual navigation mode before calling cursor.movePosition(). Visual navigation mode is Qt's mechanism for preserving the cursor's horizontal position when moving vertically through lines of different lengths, using the verticalMovementX property.
However, the custom moveCursorImpl method calculates the X position from the current cursor position each time (lines 372, 389), without utilizing Qt's vertical position memory mechanism. This causes the cursor to lose its original column position when moving through shorter lines.
For Gerrit Dashboard: QTCREATORBUG-33321 | ||||||
---|---|---|---|---|---|---|
# | Subject | Branch | Project | Status | CR | V |
668989,3 | Utils: fix vertical text cursor movement | master | qt-creator/qt-creator | Status: MERGED | +2 | 0 |