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,
|
Callback &&callback,
|
||||||
const style::InfiniteRadialAnimation &st);
|
const style::InfiniteRadialAnimation &st);
|
||||||
|
|
||||||
bool animating() const {
|
[[nodiscard]] bool animating() const {
|
||||||
return _animation.animating();
|
return _animation.animating();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -89,7 +89,7 @@ public:
|
||||||
QSize size,
|
QSize size,
|
||||||
int outerWidth);
|
int outerWidth);
|
||||||
|
|
||||||
RadialState computeState();
|
[[nodiscard]] RadialState computeState();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
const style::InfiniteRadialAnimation &_st;
|
const style::InfiniteRadialAnimation &_st;
|
||||||
|
|
|
||||||
|
|
@ -3214,6 +3214,17 @@ TextForMimeData String::toText(
|
||||||
if (composeExpanded) {
|
if (composeExpanded) {
|
||||||
result.expanded.reserve(_text.size());
|
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 linkStart = 0;
|
||||||
auto markdownTrackers = composeEntities
|
auto markdownTrackers = composeEntities
|
||||||
? std::vector<MarkdownTagTracker>{
|
? std::vector<MarkdownTagTracker>{
|
||||||
|
|
@ -3231,7 +3242,7 @@ TextForMimeData String::toText(
|
||||||
for (auto &tracker : markdownTrackers) {
|
for (auto &tracker : markdownTrackers) {
|
||||||
const auto flag = tracker.flag;
|
const auto flag = tracker.flag;
|
||||||
if ((oldFlags & flag) && !(newFlags & flag)) {
|
if ((oldFlags & flag) && !(newFlags & flag)) {
|
||||||
result.rich.entities.push_back({
|
insertEntity({
|
||||||
tracker.type,
|
tracker.type,
|
||||||
tracker.start,
|
tracker.start,
|
||||||
result.rich.text.size() - tracker.start });
|
result.rich.text.size() - tracker.start });
|
||||||
|
|
@ -3264,7 +3275,7 @@ TextForMimeData String::toText(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (composeEntities) {
|
if (composeEntities) {
|
||||||
result.rich.entities.push_back({
|
insertEntity({
|
||||||
entity.type,
|
entity.type,
|
||||||
linkStart,
|
linkStart,
|
||||||
full.size(),
|
full.size(),
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue