@@ -247,14 +247,21 @@ void Textbuf::DeleteText(uint16_t from,
this->bytes -= to - from;
this->chars -= c;
auto fixup = [&](uint16_t &pos) {
if (pos <= from) return;
if (pos <= to) {
pos = from;
} else {
pos -= to - from;
}
};
/* Fixup caret if needed. */
if (this->caretpos > from) {
if (this->caretpos <= to) {
this->caretpos = from;
this->caretpos -= to - from;
fixup(this->caretpos);
/* Fixup marked text if needed. */
fixup(this->markpos);
fixup(this->markend);
if (update) {
this->UpdateStringIter();
Status change: