mirror of https://github.com/OpenTTD/OpenTTD
Fix: marked text was not updated during text deletion (#11293)
parent
fca62c245f
commit
b4ff06b6ef
|
@ -247,14 +247,21 @@ void Textbuf::DeleteText(uint16_t from, uint16_t to, bool update)
|
||||||
this->bytes -= to - from;
|
this->bytes -= to - from;
|
||||||
this->chars -= c;
|
this->chars -= c;
|
||||||
|
|
||||||
/* Fixup caret if needed. */
|
auto fixup = [&](uint16_t &pos) {
|
||||||
if (this->caretpos > from) {
|
if (pos <= from) return;
|
||||||
if (this->caretpos <= to) {
|
if (pos <= to) {
|
||||||
this->caretpos = from;
|
pos = from;
|
||||||
} else {
|
} 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) {
|
if (update) {
|
||||||
this->UpdateStringIter();
|
this->UpdateStringIter();
|
||||||
|
|
Loading…
Reference in New Issue