Fix formatted date quotes.

This commit is contained in:
John Preston
2026-02-24 17:17:38 +04:00
parent 90129c10d8
commit 72f690ce99
2 changed files with 14 additions and 5 deletions
@@ -291,7 +291,8 @@ MTPVector<MTPMessageEntity> EntitiesToMTP(
&& entity.type() != EntityType::Spoiler
&& entity.type() != EntityType::MentionName
&& entity.type() != EntityType::CustomUrl
&& entity.type() != EntityType::CustomEmoji) {
&& entity.type() != EntityType::CustomEmoji
&& entity.type() != EntityType::FormattedDate) {
continue;
}
@@ -450,7 +450,7 @@ int KeyboardStyle::minButtonWidth(
int(modification.skipped),
result.to - modification.position);
result.to -= shiftTo;
if (modification.position <= result.from) {
if (modification.position < result.from) {
if (modification.added) {
result.from += modification.added;
}
@@ -458,6 +458,10 @@ int KeyboardStyle::minButtonWidth(
int(modification.skipped),
result.from - modification.position);
result.from -= shiftFrom;
} else if (modification.position == result.from) {
if (!modification.skipped) {
result.from += modification.added;
}
}
}
return result;
@@ -2667,14 +2671,17 @@ SelectedQuote Element::FindSelectedQuote(
for (const auto &modification : text.modifications()) {
if (modification.position >= selection.to) {
break;
} else if (modification.position <= selection.from) {
} else if (modification.position < selection.from) {
modified.from += modification.skipped;
if (modification.added
&& modification.position < selection.from) {
if (modification.added) {
modified.from = uint16(std::max(
0,
int(modified.from) - int(modification.added)));
}
} else if (modification.position == selection.from) {
if (!modification.added) {
modified.from += modification.skipped;
}
}
modified.to += modification.skipped;
if (modification.added && modified.to > modified.from) {
@@ -2703,6 +2710,7 @@ SelectedQuote Element::FindSelectedQuote(
EntityType::StrikeOut,
EntityType::Spoiler,
EntityType::CustomEmoji,
EntityType::FormattedDate,
};
for (auto i = result.entities.begin(); i != result.entities.end();) {
const auto offset = i->offset();