Skip to content

fix: user action may change cursor insert point

shenleban tongying requested to merge slbtongying/kcalc:fix/history_panel into master

See BUG: 464234 to reproduce the bug.

The history panel relies on Cursor's position to insert text.

Although the cursor is hidden, user actions like clicking or selecting will change the cursor's location.

Thus new str will be inserted to the new cursor location.


We want to track the cursor location when inserting new str.

So, we keep a textCursor when inserting str finished, and when adding new str, we set the textCursor to the previous position.

Note that this.textCursor()->setPosition() does nothing. this.textCursor() doesn't return a pointer to the internal cursor (which has no direct way to interact with).

https://doc.qt.io/qt-6/qtextedit.html#textCursor

Edited by shenleban tongying

Merge request reports

Loading