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:
Levi Neely 2026-07-16 14:45:26 +02:00
parent f45cb8199d
commit e2d02152e4
1 changed files with 7 additions and 1 deletions

View File

@ -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()));