mirror of
https://github.com/JGRennison/OpenTTD-patches.git
synced 2024-10-31 15:20:10 +00:00
Fix: marked text was not updated during text deletion (#11293)
(cherry picked from commit b4ff06b6ef
)
This commit is contained in:
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…
Reference in New Issue
Block a user