telegramdesktop / tdesktop

Telegram Desktop messaging app
https://desktop.telegram.org/
Other
26.23k stars 5.2k forks source link

"You've reached the message text limit." counts remaining text wrong #27389

Closed cw2k closed 8 months ago

cw2k commented 9 months ago

Steps to reproduce

  1. Create a message that is 4096 long. Like this: 0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789 0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789 0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789 0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789 0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789 0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789 0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789 0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789 0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789 0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789 0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789 0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789 0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789 0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789 0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789 0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789 0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789 0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789 0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789 0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789 0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789 0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789 0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789 0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789 0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789 0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789 0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789 0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789 0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789 0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789 0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789 0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789 0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789 0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789 0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789 0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789 0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789 0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789 0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789 0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456
  2. Now edit the message and add one character. For ex 7

Expected behaviour

  1. error message: "You've reached the message text limit. Please make the text shorter by 1 character."

Actual behaviour

  1. error message: "You've reached the message text limit. Please make the text shorter by 159 character."

Operating system

Manjaro Linux with xfce4 4.18

Version of Telegram Desktop

4.14.9

Installation source

Snap

Crash ID

No response

Logs

No logs needed.

Some notes: Searching for "lng_edit_limit_reached" in the Telegram sources on github will get you to a good starting point for analyzing this bug.

Here some lines above in the source the textual length of a message is calculated: /Telegram/SourceFiles/history/history_widget.cpp Line 3864

LevStolpner commented 8 months ago

Can confirm, got the same issue while editing my Saved Messages, and on size ~1200 characters it tells me that I need to shorten it by 300. In your example, when I add "7" in the end, it suggests shortening message by 3073 characters, so it's definitely broken. I'm currently on version 4.14.16, Windows 10.

Aokromes commented 8 months ago

notice unicode characters may alter message limit count.

hsvt commented 8 months ago

Please return to the previous behavior, I have the same problem and now I can’t edit my old notes if they are more than 1024 characters

eldepor commented 8 months ago

Please return to the previous behavior, I have the same problem and now I can’t edit my old notes if they are more than 1024 characters

Having the exact same issue. The text limit has decreased like crazy since last update. Most of my notes are out of range now and shows -999 in red.

Aokromes commented 8 months ago

https://github.com/telegramdesktop/tdesktop/commit/dd6cbd2c36bea80216100f128ba54da4bd314a10

lcswillems commented 8 months ago

@Aokromes When will it be released? :pray: As this is very annoying. I really need to edit a message I've written.

Aokromes commented 8 months ago

@Aokromes When will it be released? 🙏 As this is very annoying. I really need to edit a message I've written.

idk, you may want to download .15 portable and edit that message.

lcswillems commented 8 months ago

.15 was released 1 week ago, but the fix landed yesterday. How could .15 contain the fix?

Aokromes commented 8 months ago

.15 was released 1 week ago, but the fix landed yesterday. How could .15 contain the fix?

the bug was added on .16 so using .15 portable will allow you to avoid the bug to edit that message.

eldepor commented 8 months ago

thanks for fixing

Aokromes commented 8 months ago

https://github.com/telegramdesktop/tdesktop/releases/tag/v4.15.0 must be fixed on 4.15.0

awesome-Leni commented 8 months ago

Thanks for fixing the bug so quickly!