mirror of
https://github.com/Chatterino/chatterino2.git
synced 2024-11-13 19:49:51 +01:00
Fixed too much text being copied when copying chat messages (#4812)
* fix: selection copying too much * chore: add changelog entry * Update changelog entry --------- Co-authored-by: Rasmus Karlsson <rasmus.karlsson@pajlada.com>
This commit is contained in:
parent
dc62e8248b
commit
3265df7661
|
@ -11,6 +11,7 @@
|
|||
- Bugfix: Fixed Usercard popup not floating on tiling WMs on Linux when "Automatically close user popup when it loses focus" setting is enabled. (#3511)
|
||||
- Bugfix: Fixed selection of tabs after closing a tab when using "Live Tabs Only". (#4770)
|
||||
- Bugfix: Fixed input in reply thread popup losing focus when dragging. (#4815)
|
||||
- Bugfix: Fixed too much text being copied when copying chat messages. (#4812)
|
||||
- Dev: Fixed UTF16 encoding of `modes` file for the installer. (#4791)
|
||||
- Dev: Temporarily disable High DPI scaling on Qt6 builds on Windows. (#4767)
|
||||
- Dev: Tests now run on Ubuntu 22.04 instead of 20.04 to loosen C++ restrictions in tests. (#4774)
|
||||
|
|
|
@ -478,6 +478,11 @@ void MessageLayoutContainer::end()
|
|||
this->lines_.back().endIndex = this->elements_.size();
|
||||
this->lines_.back().endCharIndex = this->charIndex_;
|
||||
}
|
||||
|
||||
if (!this->elements_.empty())
|
||||
{
|
||||
this->elements_.back()->setTrailingSpace(false);
|
||||
}
|
||||
}
|
||||
|
||||
bool MessageLayoutContainer::canCollapse()
|
||||
|
@ -849,7 +854,7 @@ void MessageLayoutContainer::addSelectionText(QString &str, uint32_t from,
|
|||
element->addCopyTextToString(str, from - index, to - index);
|
||||
first = false;
|
||||
|
||||
if (index + indexCount > to)
|
||||
if (index + indexCount >= to)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
@ -857,7 +862,7 @@ void MessageLayoutContainer::addSelectionText(QString &str, uint32_t from,
|
|||
}
|
||||
else
|
||||
{
|
||||
if (index + indexCount > to)
|
||||
if (index + indexCount >= to)
|
||||
{
|
||||
element->addCopyTextToString(str, 0, to - index);
|
||||
break;
|
||||
|
|
|
@ -125,9 +125,9 @@ void ImageLayoutElement::addCopyTextToString(QString &str, uint32_t from,
|
|||
{
|
||||
str += emoteElement->getEmote()->getCopyString();
|
||||
str = TwitchEmotes::cleanUpEmoteCode(str);
|
||||
if (this->hasTrailingSpace())
|
||||
if (this->hasTrailingSpace() && to >= 2)
|
||||
{
|
||||
str += " ";
|
||||
str += ' ';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -217,9 +217,9 @@ void LayeredImageLayoutElement::addCopyTextToString(QString &str, uint32_t from,
|
|||
{
|
||||
// cleaning is taken care in call
|
||||
str += layeredEmoteElement->getCleanCopyString();
|
||||
if (this->hasTrailingSpace())
|
||||
if (this->hasTrailingSpace() && to >= 2)
|
||||
{
|
||||
str += " ";
|
||||
str += ' ';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -416,9 +416,9 @@ void TextLayoutElement::addCopyTextToString(QString &str, uint32_t from,
|
|||
{
|
||||
str += this->getText().mid(from, to - from);
|
||||
|
||||
if (this->hasTrailingSpace())
|
||||
if (this->hasTrailingSpace() && to > this->getText().length())
|
||||
{
|
||||
str += " ";
|
||||
str += ' ';
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -609,6 +609,11 @@ QString ChannelView::getSelectedText()
|
|||
: layout->getLastCharacterIndex() + 1;
|
||||
|
||||
layout->addSelectionText(result, from, to);
|
||||
|
||||
if (msg != indexEnd)
|
||||
{
|
||||
result += '\n';
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
|
|
Loading…
Reference in a new issue