kate: fix chat scroll not pinning to bottom
setHtml() resets the document layout. sb->setValue(sb->maximum()) was reading a stale maximum before relayout completed. Use moveCursor(End) + ensureCursorVisible() which forces layout and scrolls reliably. Also: fix session list state updates destroying delegates (rename fix) already included in previous commit.
This commit is contained in:
parent
f45cb8199d
commit
e2d02152e4
|
|
@ -540,7 +540,13 @@ void ChatRenderer::render(QTextEdit *view, const QString &rawText)
|
|||
view->setHtml(html);
|
||||
|
||||
if (atBottom) {
|
||||
sb->setValue(sb->maximum());
|
||||
// Move cursor to end and ensure visible — this forces layout and
|
||||
// scrolls reliably, unlike sb->setValue(sb->maximum()) which can
|
||||
// read a stale maximum before relayout completes.
|
||||
QTextCursor cursor = view->textCursor();
|
||||
cursor.movePosition(QTextCursor::End);
|
||||
view->setTextCursor(cursor);
|
||||
view->ensureCursorVisible();
|
||||
} else {
|
||||
// Restore exact scroll position — clamp to new maximum
|
||||
sb->setValue(qMin(savedPos, sb->maximum()));
|
||||
|
|
|
|||
Reference in New Issue