Tweak selection-undo interaction with WinDisplay hooks
Each selection undo operation is surrounded by pair of begin_edition()/end_edition() calls. The original reason for adding these was that in one of my preliminary versions, a WinDisplay hook could break an undo chain, even if the hook did not affect selections at all. This has since been fixed. By surrounding the undo with begin_edition()/end_edition(), try to ensure that any selection modification that happens in a WinDisplay hook would not break the undo chain. Essentially this means that, after using <c-h> to undo a buffer change, this was meant to make sure that <c-k> could redo that buffer change. However, it turns out this actually doesn't work. The attached test case triggers an assertion. As described in the first paragraph, the only real-world motivation for this is gone, so let's simplify the behavior. The assertion fix means that we can test the next commit better.
This commit is contained in:
parent
8e8c2fb46d
commit
8427379a5d
|
@ -225,11 +225,6 @@ void Context::SelectionHistory::undo()
|
|||
if (in_edition())
|
||||
throw runtime_error("selection undo is only supported at top-level");
|
||||
kak_assert(not empty());
|
||||
begin_edition();
|
||||
auto end = on_scope_end([&] {
|
||||
kak_assert(current_history_node().selections == m_staging->selections);
|
||||
end_edition();
|
||||
});
|
||||
HistoryId next;
|
||||
if constexpr (backward)
|
||||
next = current_history_node().parent;
|
||||
|
@ -242,7 +237,6 @@ void Context::SelectionHistory::undo()
|
|||
m_history_id = next;
|
||||
if constexpr (backward)
|
||||
current_history_node().redo_child = previous_id;
|
||||
m_staging = current_history_node();
|
||||
};
|
||||
Buffer& destination_buffer = history_node(next).selections.buffer();
|
||||
if (&destination_buffer == &m_context.buffer())
|
||||
|
|
1
test/normal/selection-undo/windisplay-hook/cmd
Normal file
1
test/normal/selection-undo/windisplay-hook/cmd
Normal file
|
@ -0,0 +1 @@
|
|||
|
3
test/normal/selection-undo/windisplay-hook/in
Normal file
3
test/normal/selection-undo/windisplay-hook/in
Normal file
|
@ -0,0 +1,3 @@
|
|||
1
|
||||
2
|
||||
3
|
3
test/normal/selection-undo/windisplay-hook/out
Normal file
3
test/normal/selection-undo/windisplay-hook/out
Normal file
|
@ -0,0 +1,3 @@
|
|||
1
|
||||
2
|
||||
here3
|
1
test/normal/selection-undo/windisplay-hook/rc
Normal file
1
test/normal/selection-undo/windisplay-hook/rc
Normal file
|
@ -0,0 +1 @@
|
|||
hook global WinDisplay .*/out %{exec j}
|
2
test/normal/selection-undo/windisplay-hook/script
Normal file
2
test/normal/selection-undo/windisplay-hook/script
Normal file
|
@ -0,0 +1,2 @@
|
|||
ui_out -ignore 4
|
||||
ui_in '{ "jsonrpc": "2.0", "method": "keys", "params": [ "j:buffer *debug*<ret><c-h>ihere<esc>" ] }'
|
Loading…
Reference in New Issue
Block a user