Skip to content

Commit

Permalink
Apply Ui::Text::String modifications in highlighting.
Browse files Browse the repository at this point in the history
  • Loading branch information
john-preston committed Nov 10, 2023
1 parent f7ea0e1 commit c530d7c
Showing 1 changed file with 21 additions and 15 deletions.
36 changes: 21 additions & 15 deletions Telegram/SourceFiles/history/view/history_view_element.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1673,21 +1673,27 @@ TextSelection Element::FindSelectionFromQuote(
}
offset = i + 1;
}
//for (const auto &modification : text.modifications()) {
// if (modification.position >= selection.to) {
// break;
// } else if (modification.position <= selection.from) {
// modified.from += modification.skipped;
// if (modification.added
// && modification.position < selection.from) {
// --modified.from;
// }
// }
// modified.to += modification.skipped;
// if (modification.added && modified.to > modified.from) {
// --modified.to;
// }
//}
for (const auto &modification : text.modifications()) {
if (modification.position >= result.to) {
break;
}
if (modification.added) {
++result.to;
}
const auto shiftTo = std::min(
int(modification.skipped),
result.to - modification.position);
result.to -= shiftTo;
if (modification.position <= result.from) {
if (modification.added) {
++result.from;
}
const auto shiftFrom = std::min(
int(modification.skipped),
result.from - modification.position);
result.from -= shiftFrom;
}
}
return result;
}

Expand Down

0 comments on commit c530d7c

Please sign in to comment.