diff --git a/CHANGELOG.md b/CHANGELOG.md index a495f4f51..9b2566718 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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) diff --git a/src/messages/layouts/MessageLayoutContainer.cpp b/src/messages/layouts/MessageLayoutContainer.cpp index 540e9dfac..8f2797880 100644 --- a/src/messages/layouts/MessageLayoutContainer.cpp +++ b/src/messages/layouts/MessageLayoutContainer.cpp @@ -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;