Changeset - r27909:22b157092ade
[Not reviewed]
master
0 1 0
Loïc Guilloux - 8 months ago 2023-09-13 20:59:34
glx22@users.noreply.github.com
Fix: marked text was not updated during text deletion (#11293)
1 file changed with 14 insertions and 7 deletions:
0 comments (0 inline, 0 general)
src/textbuf.cpp
Show inline comments
 
@@ -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;
 
		} else {
 
			this->caretpos -= to - from;
 
		}
 
	}
 
	fixup(this->caretpos);
 

	
 
	/* Fixup marked text if needed. */
 
	fixup(this->markpos);
 
	fixup(this->markend);
 

	
 
	if (update) {
 
		this->UpdateStringIter();
0 comments (0 inline, 0 general)