Fix: marked text was not updated during text deletion (#11293)

(cherry picked from commit b4ff06b6ef)
pull/603/head
Loïc Guilloux 9 months ago committed by Jonathan G Rennison
parent 4c4fe8cf64
commit cb5a132b0c

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

Loading…
Cancel
Save