From 699c70ac91304078cdf4a8fee6d1737553f96606 Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Sat, 23 Mar 2024 20:02:16 +1100 Subject: [PATCH] Add some missing ScopedEdition and fix redo tabs <-> space conversion functions did not create a ScopedEdition leading to uncommited modifications. Fixing this did fix the interactive error, but that error still existed in non interactive context so redo now considers there there is no redo child if there are uncommited modifiations (which is correct as this means we are currently creating a new leaf in the undo tree) Fixes #5124 --- src/buffer.cc | 5 ++--- src/normal.cc | 2 ++ test/regression/5124-assert-in-redo/cmd | 1 + test/regression/5124-assert-in-redo/in | 1 + test/regression/5124-assert-in-redo/out | 1 + 5 files changed, 7 insertions(+), 3 deletions(-) create mode 100644 test/regression/5124-assert-in-redo/cmd create mode 100644 test/regression/5124-assert-in-redo/in create mode 100644 test/regression/5124-assert-in-redo/out diff --git a/src/buffer.cc b/src/buffer.cc index ffb45e18..ada61ad8 100644 --- a/src/buffer.cc +++ b/src/buffer.cc @@ -321,11 +321,10 @@ bool Buffer::redo(size_t count) { throw_if_read_only(); - if (current_history_node().redo_child == HistoryId::Invalid) + if (current_history_node().redo_child == HistoryId::Invalid or + not m_current_undo_group.empty()) return false; - kak_assert(m_current_undo_group.empty()); - while (count-- != 0 and current_history_node().redo_child != HistoryId::Invalid) { m_history_id = current_history_node().redo_child; diff --git a/src/normal.cc b/src/normal.cc index 03e7895c..2d80d26f 100644 --- a/src/normal.cc +++ b/src/normal.cc @@ -1705,6 +1705,7 @@ void tabs_to_spaces(Context& context, NormalParams params) Vector tabs; Vector spaces; ScopedSelectionEdition selection_edition{context}; + ScopedEdition edition{context}; for (auto& sel : context.selections()) { for (auto it = buffer.iterator_at(sel.min()), @@ -1730,6 +1731,7 @@ void spaces_to_tabs(Context& context, NormalParams params) const ColumnCount tabstop = params.count == 0 ? opt_tabstop : params.count; Vector spaces; ScopedSelectionEdition selection_edition{context}; + ScopedEdition edition{context}; for (auto& sel : context.selections()) { for (auto it = buffer.iterator_at(sel.min()), diff --git a/test/regression/5124-assert-in-redo/cmd b/test/regression/5124-assert-in-redo/cmd new file mode 100644 index 00000000..7e408326 --- /dev/null +++ b/test/regression/5124-assert-in-redo/cmd @@ -0,0 +1 @@ +%duU diff --git a/test/regression/5124-assert-in-redo/in b/test/regression/5124-assert-in-redo/in new file mode 100644 index 00000000..e7d712ce --- /dev/null +++ b/test/regression/5124-assert-in-redo/in @@ -0,0 +1 @@ +foo bar diff --git a/test/regression/5124-assert-in-redo/out b/test/regression/5124-assert-in-redo/out new file mode 100644 index 00000000..9a9b36bb --- /dev/null +++ b/test/regression/5124-assert-in-redo/out @@ -0,0 +1 @@ +foo bar