Fix: marked text was not updated during text deletion (#11293)
(cherry picked from commit b4ff06b6ef
)
This commit is contained in:

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;
|
if (this->markend >= this->bytes) this->markpos = this->markend = 0;
|
||||||
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();
|
||||||
|
Reference in New Issue
Block a user