From 1b4c95e4dd65b924a3868bf751a5f204228b20cf Mon Sep 17 00:00:00 2001 From: Allen Webster Date: Fri, 22 Mar 2019 13:08:06 -0700 Subject: [PATCH] Batch edit fix --- 4ed_edit.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/4ed_edit.cpp b/4ed_edit.cpp index 8ab90a50..e4c080f9 100644 --- a/4ed_edit.cpp +++ b/4ed_edit.cpp @@ -315,9 +315,15 @@ edit_single(System_Functions *system, Models *models, Editing_File *file, Edit e // TODO(allen): this isn't "real" anymore, batch edits are now superseded a combination of other features, we should dump this someday internal void edit_batch(System_Functions *system, Models *models, Editing_File *file, Edit_Array edits, Edit_Behaviors behaviors){ - Edit *edit = edits.vals; - for (i32 i = 0; i < edits.count; i += 1, edit += 1){ - edit_single(system, models, file, *edit, behaviors); + Edit *edit_ptr = edits.vals; + i32 shift = 0; + for (i32 i = 0; i < edits.count; i += 1, edit_ptr += 1){ + Edit edit = *edit_ptr; + i32 shift_change = edit.length - (edit.range.one_past_last - edit.range.first); + edit.range.first += shift; + edit.range.one_past_last += shift; + edit_single(system, models, file, edit, behaviors); + shift += shift_change; } }