More proper offseting of cursors during char insert
This commit is contained in:
@@ -209,11 +209,16 @@ int main() {
|
||||
AddEdit(&edits, it, string);
|
||||
}
|
||||
ApplyEdits(&focused_window->buffer, edits);
|
||||
For(focused_window->cursors) {
|
||||
// Need to update current cursor and all cursors after it.
|
||||
|
||||
ForItem(edit, edits) {
|
||||
int64_t remove_size = GetRangeSize(edit.range);
|
||||
int64_t add_size = string.len;
|
||||
int64_t offset = add_size - remove_size;
|
||||
|
||||
ForItem(cursor, focused_window->cursors) {
|
||||
if (cursor.min >= it.min) {
|
||||
cursor.min = cursor.max = MoveRight(focused_window->buffer, cursor.min);
|
||||
if (edit.range.min <= cursor.min) {
|
||||
cursor.min += offset;
|
||||
cursor.max = cursor.min;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user