From f34e62f24a7bb6e9a652486ac432d1ce4711af87 Mon Sep 17 00:00:00 2001 From: John Preston Date: Tue, 21 Apr 2026 16:26:32 +0700 Subject: [PATCH] Fix text appearing height animation. --- .../history/view/history_view_message.cpp | 13 ++++++------- .../SourceFiles/history/view/history_view_message.h | 4 +++- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/Telegram/SourceFiles/history/view/history_view_message.cpp b/Telegram/SourceFiles/history/view/history_view_message.cpp index 57f8e60f87..7823de3d72 100644 --- a/Telegram/SourceFiles/history/view/history_view_message.cpp +++ b/Telegram/SourceFiles/history/view/history_view_message.cpp @@ -5153,7 +5153,7 @@ int Message::resizeContentGetHeight(int newWidth) { } if (!mediaDisplayed && bubble && hasVisibleText()) { const auto probeTextWidth = bubbleTextWidth(contentWidth); - [[maybe_unused]] const auto probeHeight = textHeightFor(probeTextWidth); + [[maybe_unused]] const auto probe = textHeightFor(probeTextWidth); if (!Get()) { const auto use = textRealWidth(); if (use > 0) { @@ -5439,7 +5439,7 @@ bool Message::textAppearCheckLine(not_null appearing) { if (appearing->heightAnimation.animating() || !appearing->widthAnimation.animating() || left <= duration) { - textAppearStartHeightAnimation(appearing); + textAppearStartHeightAnimation(appearing, targetHeight); } } } @@ -5477,13 +5477,12 @@ void Message::textAppearStartWidthAnimation( } void Message::textAppearStartHeightAnimation( - not_null appearing) { + not_null appearing, + int targetHeight) { Expects(appearing->use); const auto from = appearing->shownHeight; - const auto to - = appearing->targetHeight - = textAppearTargetHeight(appearing); + const auto to = appearing->targetHeight = targetHeight; const auto duration = appearing->finalizing ? kLineHeightAppearFinalDuration : kLineHeightAppearDuration; @@ -5496,7 +5495,7 @@ int Message::textAppearTargetHeight( not_null appearing) const { const auto next = appearing->shownLine + 1; const auto lines = int(appearing->lines.size()); - if (next >= lines) { + if (next + 1 >= lines) { return appearing->lines.back().bottom; } const auto &line = appearing->lines[next]; diff --git a/Telegram/SourceFiles/history/view/history_view_message.h b/Telegram/SourceFiles/history/view/history_view_message.h index bb6d27e3f3..e65a82a67a 100644 --- a/Telegram/SourceFiles/history/view/history_view_message.h +++ b/Telegram/SourceFiles/history/view/history_view_message.h @@ -397,7 +397,9 @@ private: bool textAppearValidate(not_null appearing); bool textAppearCheckLine(not_null appearing); void textAppearStartWidthAnimation(not_null appearing); - void textAppearStartHeightAnimation(not_null appearing); + void textAppearStartHeightAnimation( + not_null appearing, + int targetHeight); void textAppearWidthCallback(); void textAppearHeightCallback(); [[nodiscard]] int textAppearTargetHeight(