Details
-
Bug
-
Resolution: Done
-
P2: Important
-
6.2.1, 6.2.2
-
None
-
-
8b3f2dd994 (qt/qtbase/dev) 8b3f2dd994 (qt/tqtc-qtbase/dev) 567d047c4e (qt/tqtc-qtbase/6.2) 6d41c144ae (qt/qtbase/6.3) 6d41c144ae (qt/tqtc-qtbase/6.3)
Description
Steps to reproduce:
- Create QPlainTextEdit with enough text data to be able to scroll
- Put cursor on first line
- Scroll down, so cursor goes out of view
- Switch to another application and back
Expected result:
Scroll position remains unchanged, cursor is out of view
Actual result:
Scroll position changed, it scrolled up to ensure cursor is visible
Sample code to reproduce the issue:
#include <QApplication> #include <QPlainTextEdit> int main(int argc, char *argv[]) { QApplication a(argc, argv); QPlainTextEdit e; const QString text = "Quidem soluta at dolores autem voluptatem nisi impedit. Et sint eligendi consectetur. Explicabo quos molestias error. Sit saepe tempore sint delectus qui quo. Magni veritatis ut debitis a ipsum." "Officia dolorum iure dicta consequatur. Aut similique nihil ea ut voluptates eos. Qui in asperiores omnis eum tempore. Dolor reprehenderit accusantium ratione necessitatibus perferendis quo voluptatem error." "Quam ratione voluptas qui in et. Qui eveniet id adipisci molestiae et rerum et. Voluptas provident ducimus et earum. Veritatis facilis unde sunt. Id voluptatum ullam aut labore et sapiente iure." "Culpa illum mollitia aliquam ut. Totam eum repellat harum placeat a commodi. Architecto assumenda omnis et. Reiciendis facilis dignissimos omnis consequatur." "A laudantium harum eius suscipit. Veritatis aspernatur dolorem ipsa sit. Nobis repellendus dolorem dolore alias quia. Cupiditate quidem ut ea."; e.setPlainText(text); e.show(); return a.exec(); }
This is a cause of QTCREATORBUG-26628
Video of a problem:
Video without a problem when filtering empty QInputMethod events. Also, input method demonstrated (ctrl-shift-u, 123, enter):
I have no environment set to build Qt libraries, but the fix would be to check for empty input method events and don't scroll to cursor.
// qplaintextedit.cpp:2206 void QPlainTextEdit::inputMethodEvent(QInputMethodEvent *e) { ... const bool emptyEvent = e->preeditString().isEmpty() && e->commitString().isEmpty() && e->attributes().isEmpty(); if (!emptyEvent) { ensureCursorVisible(); } }
Attachments
Issue Links
- is duplicated by
-
QTCREATORBUG-26628 Switching from Creator to other window changes scroll position in editor
- Closed