From 2e2cdfdb81a12b30a4a0929fc7cc2db78c9590b3 Mon Sep 17 00:00:00 2001 From: Josh Holtrop Date: Sun, 15 Jan 2017 20:58:18 -0500 Subject: [PATCH] bug fix: when applying change operations in reverse, apply their change units in reverse order --- src/core/Buffer.cc | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/core/Buffer.cc b/src/core/Buffer.cc index 9f4856a..be08f6d 100644 --- a/src/core/Buffer.cc +++ b/src/core/Buffer.cc @@ -387,9 +387,21 @@ void Buffer::save_current_operation() void Buffer::apply_change_operation(const ChangeOperation & change_operation, bool forward) { - for (auto change_unit : change_operation.changes) + if (forward) { - apply_change_unit(change_unit, forward); + for (auto change_unit : change_operation.changes) + { + apply_change_unit(change_unit, forward); + } + } + else + { + for (auto i = change_operation.changes.rbegin(); + i != change_operation.changes.rend(); + i++) + { + apply_change_unit(*i, forward); + } } }