mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-06 23:24:01 +02:00
Don't check quote entities now that we have quote_offset.
This commit is contained in:
parent
3a67e4f1f4
commit
4ad70965e9
1 changed files with 1 additions and 40 deletions
|
@ -95,42 +95,6 @@ Element *MousedElement/* = nullptr*/;
|
||||||
return session->tryResolveWindow();
|
return session->tryResolveWindow();
|
||||||
}
|
}
|
||||||
|
|
||||||
[[nodiscard]] bool CheckQuoteEntities(
|
|
||||||
const EntitiesInText "eEntities,
|
|
||||||
const TextWithEntities &original,
|
|
||||||
TextSelection selection) {
|
|
||||||
auto left = quoteEntities;
|
|
||||||
const auto allowed = std::array{
|
|
||||||
EntityType::Bold,
|
|
||||||
EntityType::Italic,
|
|
||||||
EntityType::Underline,
|
|
||||||
EntityType::StrikeOut,
|
|
||||||
EntityType::Spoiler,
|
|
||||||
EntityType::CustomEmoji,
|
|
||||||
};
|
|
||||||
for (const auto &entity : original.entities) {
|
|
||||||
const auto from = entity.offset();
|
|
||||||
const auto till = from + entity.length();
|
|
||||||
if (till <= selection.from || from >= selection.to) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
const auto quoteFrom = std::max(from, int(selection.from));
|
|
||||||
const auto quoteTill = std::min(till, int(selection.to));
|
|
||||||
const auto cut = EntityInText(
|
|
||||||
entity.type(),
|
|
||||||
quoteFrom - int(selection.from),
|
|
||||||
quoteTill - quoteFrom,
|
|
||||||
entity.data());
|
|
||||||
const auto i = ranges::find(left, cut);
|
|
||||||
if (i != left.end()) {
|
|
||||||
left.erase(i);
|
|
||||||
} else if (ranges::contains(allowed, cut.type())) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return left.empty();
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
std::unique_ptr<Ui::PathShiftGradient> MakePathShiftGradient(
|
std::unique_ptr<Ui::PathShiftGradient> MakePathShiftGradient(
|
||||||
|
@ -1662,13 +1626,10 @@ TextSelection Element::FindSelectionFromQuote(
|
||||||
const auto length = int(original.text.size());
|
const auto length = int(original.text.size());
|
||||||
const auto qlength = int(quote.text.text.size());
|
const auto qlength = int(quote.text.text.size());
|
||||||
const auto checkAt = [&](int offset) {
|
const auto checkAt = [&](int offset) {
|
||||||
const auto selection = TextSelection{
|
return TextSelection{
|
||||||
uint16(offset),
|
uint16(offset),
|
||||||
uint16(offset + qlength),
|
uint16(offset + qlength),
|
||||||
};
|
};
|
||||||
return CheckQuoteEntities(quote.text.entities, original, selection)
|
|
||||||
? selection
|
|
||||||
: TextSelection{ uint16(offset + 1), uint16(offset + 1) };
|
|
||||||
};
|
};
|
||||||
const auto findOneAfter = [&](int offset) {
|
const auto findOneAfter = [&](int offset) {
|
||||||
if (offset > length - qlength) {
|
if (offset > length - qlength) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue