From 8e8c2fb46d418236918c0dbddad8e48ae9e4e20d Mon Sep 17 00:00:00 2001 From: Johannes Altmanninger Date: Sat, 3 Dec 2022 19:23:24 +0100 Subject: Add tests for selection undo --- test/normal/selection-undo/redo/cmd | 1 + test/normal/selection-undo/redo/in | 4 ++++ test/normal/selection-undo/redo/out | 4 ++++ test/normal/selection-undo/redo/script | 2 ++ test/normal/selection-undo/undo/cmd | 1 + test/normal/selection-undo/undo/in | 4 ++++ test/normal/selection-undo/undo/out | 4 ++++ test/normal/selection-undo/undo/script | 2 ++ 8 files changed, 22 insertions(+) create mode 100644 test/normal/selection-undo/redo/cmd create mode 100644 test/normal/selection-undo/redo/in create mode 100644 test/normal/selection-undo/redo/out create mode 100644 test/normal/selection-undo/redo/script create mode 100644 test/normal/selection-undo/undo/cmd create mode 100644 test/normal/selection-undo/undo/in create mode 100644 test/normal/selection-undo/undo/out create mode 100644 test/normal/selection-undo/undo/script (limited to 'test/normal') diff --git a/test/normal/selection-undo/redo/cmd b/test/normal/selection-undo/redo/cmd new file mode 100644 index 00000000..8b137891 --- /dev/null +++ b/test/normal/selection-undo/redo/cmd @@ -0,0 +1 @@ + diff --git a/test/normal/selection-undo/redo/in b/test/normal/selection-undo/redo/in new file mode 100644 index 00000000..94ebaf90 --- /dev/null +++ b/test/normal/selection-undo/redo/in @@ -0,0 +1,4 @@ +1 +2 +3 +4 diff --git a/test/normal/selection-undo/redo/out b/test/normal/selection-undo/redo/out new file mode 100644 index 00000000..76bef247 --- /dev/null +++ b/test/normal/selection-undo/redo/out @@ -0,0 +1,4 @@ +1 +2 +here3 +4 diff --git a/test/normal/selection-undo/redo/script b/test/normal/selection-undo/redo/script new file mode 100644 index 00000000..c92d82d7 --- /dev/null +++ b/test/normal/selection-undo/redo/script @@ -0,0 +1,2 @@ +ui_out -ignore 4 +ui_in '{ "jsonrpc": "2.0", "method": "keys", "params": [ "2jjihere" ] }' diff --git a/test/normal/selection-undo/undo/cmd b/test/normal/selection-undo/undo/cmd new file mode 100644 index 00000000..8b137891 --- /dev/null +++ b/test/normal/selection-undo/undo/cmd @@ -0,0 +1 @@ + diff --git a/test/normal/selection-undo/undo/in b/test/normal/selection-undo/undo/in new file mode 100644 index 00000000..94ebaf90 --- /dev/null +++ b/test/normal/selection-undo/undo/in @@ -0,0 +1,4 @@ +1 +2 +3 +4 diff --git a/test/normal/selection-undo/undo/out b/test/normal/selection-undo/undo/out new file mode 100644 index 00000000..00a7e5fd --- /dev/null +++ b/test/normal/selection-undo/undo/out @@ -0,0 +1,4 @@ +here1 +2 +3 +4 diff --git a/test/normal/selection-undo/undo/script b/test/normal/selection-undo/undo/script new file mode 100644 index 00000000..2b00d75e --- /dev/null +++ b/test/normal/selection-undo/undo/script @@ -0,0 +1,2 @@ +ui_out -ignore 4 +ui_in '{ "jsonrpc": "2.0", "method": "keys", "params": [ "j2jihere" ] }' -- cgit v1.2.3 From 8427379a5dfcf35af35fd5a7b26803e8727476e6 Mon Sep 17 00:00:00 2001 From: Johannes Altmanninger Date: Thu, 22 Dec 2022 18:09:45 +0100 Subject: 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 to undo a buffer change, this was meant to make sure that 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. --- test/normal/selection-undo/windisplay-hook/cmd | 1 + test/normal/selection-undo/windisplay-hook/in | 3 +++ test/normal/selection-undo/windisplay-hook/out | 3 +++ test/normal/selection-undo/windisplay-hook/rc | 1 + test/normal/selection-undo/windisplay-hook/script | 2 ++ 5 files changed, 10 insertions(+) create mode 100644 test/normal/selection-undo/windisplay-hook/cmd create mode 100644 test/normal/selection-undo/windisplay-hook/in create mode 100644 test/normal/selection-undo/windisplay-hook/out create mode 100644 test/normal/selection-undo/windisplay-hook/rc create mode 100644 test/normal/selection-undo/windisplay-hook/script (limited to 'test/normal') diff --git a/test/normal/selection-undo/windisplay-hook/cmd b/test/normal/selection-undo/windisplay-hook/cmd new file mode 100644 index 00000000..8b137891 --- /dev/null +++ b/test/normal/selection-undo/windisplay-hook/cmd @@ -0,0 +1 @@ + diff --git a/test/normal/selection-undo/windisplay-hook/in b/test/normal/selection-undo/windisplay-hook/in new file mode 100644 index 00000000..01e79c32 --- /dev/null +++ b/test/normal/selection-undo/windisplay-hook/in @@ -0,0 +1,3 @@ +1 +2 +3 diff --git a/test/normal/selection-undo/windisplay-hook/out b/test/normal/selection-undo/windisplay-hook/out new file mode 100644 index 00000000..92243f2b --- /dev/null +++ b/test/normal/selection-undo/windisplay-hook/out @@ -0,0 +1,3 @@ +1 +2 +here3 diff --git a/test/normal/selection-undo/windisplay-hook/rc b/test/normal/selection-undo/windisplay-hook/rc new file mode 100644 index 00000000..b157a2ce --- /dev/null +++ b/test/normal/selection-undo/windisplay-hook/rc @@ -0,0 +1 @@ +hook global WinDisplay .*/out %{exec j} diff --git a/test/normal/selection-undo/windisplay-hook/script b/test/normal/selection-undo/windisplay-hook/script new file mode 100644 index 00000000..d2fd1c40 --- /dev/null +++ b/test/normal/selection-undo/windisplay-hook/script @@ -0,0 +1,2 @@ +ui_out -ignore 4 +ui_in '{ "jsonrpc": "2.0", "method": "keys", "params": [ "j:buffer *debug*ihere" ] }' -- cgit v1.2.3 From 516759bb2fd95d02134bc84130bf9060e0354310 Mon Sep 17 00:00:00 2001 From: Johannes Altmanninger Date: Thu, 22 Dec 2022 18:09:45 +0100 Subject: Make selection undo skip over entries that are nop after buffer change After buffer modification - in particular after deletion - adjacent selection history entries may correspond to the same effective selection when applied to the current buffer. This means that we sometimes need to press multiple times to make one visible change. This is not what the user expects, so let's keep walking the selection history until we hit an actual change. Alternatively, we could minimize the selection history after buffer changes but I think that would make the it worse after content undo+redo. --- test/normal/selection-undo/fold-redundant-entries/cmd | 1 + test/normal/selection-undo/fold-redundant-entries/in | 4 ++++ test/normal/selection-undo/fold-redundant-entries/out | 3 +++ test/normal/selection-undo/fold-redundant-entries/script | 2 ++ 4 files changed, 10 insertions(+) create mode 100644 test/normal/selection-undo/fold-redundant-entries/cmd create mode 100644 test/normal/selection-undo/fold-redundant-entries/in create mode 100644 test/normal/selection-undo/fold-redundant-entries/out create mode 100644 test/normal/selection-undo/fold-redundant-entries/script (limited to 'test/normal') diff --git a/test/normal/selection-undo/fold-redundant-entries/cmd b/test/normal/selection-undo/fold-redundant-entries/cmd new file mode 100644 index 00000000..8b137891 --- /dev/null +++ b/test/normal/selection-undo/fold-redundant-entries/cmd @@ -0,0 +1 @@ + diff --git a/test/normal/selection-undo/fold-redundant-entries/in b/test/normal/selection-undo/fold-redundant-entries/in new file mode 100644 index 00000000..94ebaf90 --- /dev/null +++ b/test/normal/selection-undo/fold-redundant-entries/in @@ -0,0 +1,4 @@ +1 +2 +3 +4 diff --git a/test/normal/selection-undo/fold-redundant-entries/out b/test/normal/selection-undo/fold-redundant-entries/out new file mode 100644 index 00000000..239c8675 --- /dev/null +++ b/test/normal/selection-undo/fold-redundant-entries/out @@ -0,0 +1,3 @@ +2 +3 +here4 diff --git a/test/normal/selection-undo/fold-redundant-entries/script b/test/normal/selection-undo/fold-redundant-entries/script new file mode 100644 index 00000000..456f92f2 --- /dev/null +++ b/test/normal/selection-undo/fold-redundant-entries/script @@ -0,0 +1,2 @@ +ui_out -ignore 4 +ui_in '{ "jsonrpc": "2.0", "method": "keys", "params": [ "gjgkxdihere" ] }' -- cgit v1.2.3