Fix spacing issue with mentions inside RTL text (#4677)

Co-authored-by: Rasmus Karlsson <rasmus.karlsson@pajlada.com>
This commit is contained in:
mohad12211 2023-06-10 16:44:45 +03:00 committed by GitHub
parent 839ba60fd8
commit c907f2b170
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 6 deletions

View file

@ -8,6 +8,7 @@
- Minor: Improved editing hotkeys. (#4628)
- Minor: The input completion and quick switcher are now styled to match your theme. (#4671)
- Bugfix: Fixed generation of crashdumps by the browser-extension process when the browser was closed. (#4667)
- Bugfix: Fix spacing issue with mentions inside RTL text. (#4677)
- Bugfix: Fixed a crash when opening and closing a reply thread and switching the user. (#4675)
- Dev: Added command to set Qt's logging filter/rules at runtime (`/c2-set-logging-rules`). (#4637)
- Dev: Added the ability to see & load custom themes from the Themes directory. No stable promises are made of this feature, changes might be made that breaks custom themes without notice. (#4570)

View file

@ -276,17 +276,24 @@ void MessageLayoutContainer::reorderRTL(int firstTextIndex)
// 2 - in LTR mode, the previous word should be RTL (i.e. reversed)
for (int i = startIndex; i <= endIndex; i++)
{
if (isNeutral(this->elements_[i]->getText()) &&
auto &element = this->elements_[i];
const auto neutral = isNeutral(element->getText());
const auto neutralOrUsername =
neutral ||
element->getFlags().hasAny({MessageElementFlag::BoldUsername,
MessageElementFlag::NonBoldUsername});
if (neutral &&
((this->first == FirstWord::RTL && !this->wasPrevReversed_) ||
(this->first == FirstWord::LTR && this->wasPrevReversed_)))
{
this->elements_[i]->reversedNeutral = true;
element->reversedNeutral = true;
}
if (((this->elements_[i]->getText().isRightToLeft() !=
if (((element->getText().isRightToLeft() !=
(this->first == FirstWord::RTL)) &&
!isNeutral(this->elements_[i]->getText())) ||
(isNeutral(this->elements_[i]->getText()) &&
this->wasPrevReversed_))
!neutralOrUsername) ||
(neutralOrUsername && this->wasPrevReversed_))
{
swappedSequence.push(i);
this->wasPrevReversed_ = true;