Fix parsing entities from Ui::Text::String.
This commit is contained in:
parent
fcb44b320c
commit
604f62599e
2 changed files with 15 additions and 4 deletions
|
|
@ -72,7 +72,7 @@ public:
|
|||
Callback &&callback,
|
||||
const style::InfiniteRadialAnimation &st);
|
||||
|
||||
bool animating() const {
|
||||
[[nodiscard]] bool animating() const {
|
||||
return _animation.animating();
|
||||
}
|
||||
|
||||
|
|
@ -89,7 +89,7 @@ public:
|
|||
QSize size,
|
||||
int outerWidth);
|
||||
|
||||
RadialState computeState();
|
||||
[[nodiscard]] RadialState computeState();
|
||||
|
||||
private:
|
||||
const style::InfiniteRadialAnimation &_st;
|
||||
|
|
|
|||
|
|
@ -3214,6 +3214,17 @@ TextForMimeData String::toText(
|
|||
if (composeExpanded) {
|
||||
result.expanded.reserve(_text.size());
|
||||
}
|
||||
const auto insertEntity = [&](EntityInText &&entity) {
|
||||
auto i = result.rich.entities.end();
|
||||
while (i != result.rich.entities.begin()) {
|
||||
auto j = i;
|
||||
if ((--j)->offset() <= entity.offset()) {
|
||||
break;
|
||||
}
|
||||
i = j;
|
||||
}
|
||||
result.rich.entities.insert(i, std::move(entity));
|
||||
};
|
||||
auto linkStart = 0;
|
||||
auto markdownTrackers = composeEntities
|
||||
? std::vector<MarkdownTagTracker>{
|
||||
|
|
@ -3231,7 +3242,7 @@ TextForMimeData String::toText(
|
|||
for (auto &tracker : markdownTrackers) {
|
||||
const auto flag = tracker.flag;
|
||||
if ((oldFlags & flag) && !(newFlags & flag)) {
|
||||
result.rich.entities.push_back({
|
||||
insertEntity({
|
||||
tracker.type,
|
||||
tracker.start,
|
||||
result.rich.text.size() - tracker.start });
|
||||
|
|
@ -3264,7 +3275,7 @@ TextForMimeData String::toText(
|
|||
}
|
||||
}
|
||||
if (composeEntities) {
|
||||
result.rich.entities.push_back({
|
||||
insertEntity({
|
||||
entity.type,
|
||||
linkStart,
|
||||
full.size(),
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue