Skip to content

Commit

Permalink
Treat elements with usernames (mentions) as neutral elements
Browse files Browse the repository at this point in the history
  • Loading branch information
mohad12211 committed Jun 9, 2023
1 parent ca9c91a commit 3c45354
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/messages/layouts/MessageLayoutContainer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,11 @@ 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++)
{
bool neutral = isNeutral(this->elements_[i]->getText()) ||
this->elements_[i]->getFlags().hasAny(
{MessageElementFlag::BoldUsername,
MessageElementFlag::NonBoldUsername});

if (isNeutral(this->elements_[i]->getText()) &&
((this->first == FirstWord::RTL && !this->wasPrevReversed_) ||
(this->first == FirstWord::LTR && this->wasPrevReversed_)))
Expand All @@ -284,9 +289,8 @@ void MessageLayoutContainer::reorderRTL(int firstTextIndex)
}
if (((this->elements_[i]->getText().isRightToLeft() !=
(this->first == FirstWord::RTL)) &&
!isNeutral(this->elements_[i]->getText())) ||
(isNeutral(this->elements_[i]->getText()) &&
this->wasPrevReversed_))
!neutral) ||
(neutral && this->wasPrevReversed_))
{
swappedSequence.push(i);
this->wasPrevReversed_ = true;
Expand Down

0 comments on commit 3c45354

Please sign in to comment.