Fix LineEdit
caret rendering/positioning on Undo.
#87012
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #67169.
This fixes the circumstance where undoing deleted text in
LineEdit
could lead to caret appearing outside of the box. (This bug has become even easier to reproduce with recent PR #86732 , though repo steps are the same )The reason for this appears to be that in the
undo()
function, theset_caret_column()
was called before the_shape()
function. However, it seems the_shape()
function needs to be called first (as it is in other parts of theLineEdit.cpp
) as otherwise theget_caret_pixel_pos()
thatset_caret_column()
uses gives an incorrect value (that the caret is at 0, 0).I've reordered these functions in both
undo()
andredo()
and the bug now appears fixed with the caret behaving appropriately when undoing.