fix neutral elements order in multiple lines (#4173)

Co-authored-by: Rasmus Karlsson <rasmus.karlsson@pajlada.com>
This commit is contained in:
mohad12211 2022-11-25 13:24:28 +03:00 committed by GitHub
parent 330e0a99fa
commit fe2a9ccbff
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 9 additions and 6 deletions

View file

@ -5,6 +5,7 @@
- Bugfix: Fixed crash happening when QuickSwitcher is used with a popout window. (#4187)
- Bugfix: Fixed low contrast of text in settings tooltips. (#4188)
- Bugfix: Fixed being unable to see the usercard of VIPs who have Asian language display names. (#4174)
- Bugfix: Fixed messages where Right-to-Left order is mixed in multiple lines. (#4173)
- Bugfix: Fixed the wrong right-click menu showing in the chat input box. (#4177)
- Bugfix: Fixed popup windows not appearing/minimizing correctly on the Windows taskbar. (#4181)

View file

@ -48,6 +48,7 @@ void MessageLayoutContainer::begin(int width, float scale, MessageFlags flags)
this->dotdotdotWidth_ = mediumFontMetrics.horizontalAdvance("...");
this->canAddMessages_ = true;
this->isCollapsed_ = false;
this->wasPrevReversed_ = false;
}
void MessageLayoutContainer::clear()
@ -272,7 +273,6 @@ void MessageLayoutContainer::reorderRTL(int firstTextIndex)
std::vector<int> correctSequence;
std::stack<int> swappedSequence;
bool wasPrevReversed = false;
// we reverse a sequence of words if it's opposite to the text direction
// the second condition below covers the possible three cases:
@ -291,18 +291,19 @@ void MessageLayoutContainer::reorderRTL(int firstTextIndex)
for (int i = startIndex; i <= endIndex; i++)
{
if (isNeutral(this->elements_[i]->getText()) &&
((this->first == FirstWord::RTL && !wasPrevReversed) ||
(this->first == FirstWord::LTR && wasPrevReversed)))
((this->first == FirstWord::RTL && !this->wasPrevReversed_) ||
(this->first == FirstWord::LTR && this->wasPrevReversed_)))
{
this->elements_[i]->reversedNeutral = true;
}
if (((this->elements_[i]->getText().isRightToLeft() !=
(this->first == FirstWord::RTL)) &&
!isNeutral(this->elements_[i]->getText())) ||
(isNeutral(this->elements_[i]->getText()) && wasPrevReversed))
(isNeutral(this->elements_[i]->getText()) &&
this->wasPrevReversed_))
{
swappedSequence.push(i);
wasPrevReversed = true;
this->wasPrevReversed_ = true;
}
else
{
@ -312,7 +313,7 @@ void MessageLayoutContainer::reorderRTL(int firstTextIndex)
swappedSequence.pop();
}
correctSequence.push_back(i);
wasPrevReversed = false;
this->wasPrevReversed_ = false;
}
}
while (!swappedSequence.empty())

View file

@ -128,6 +128,7 @@ private:
int dotdotdotWidth_ = 0;
bool canAddMessages_ = true;
bool isCollapsed_ = false;
bool wasPrevReversed_ = false;
std::vector<std::unique_ptr<MessageLayoutElement>> elements_;
std::vector<Line> lines_;