diff options
author | Michael Davis | 2022-11-23 14:57:09 +0000 |
---|---|---|
committer | Blaž Hrastnik | 2022-11-24 01:57:12 +0000 |
commit | 94eb3de7767c5d16344bec9634028f346cd867bb (patch) | |
tree | 111244348b2c9907b5000c3da2babcb24dae0243 /helix-term | |
parent | 590a628460c8fa8a4e101541d67289fa2fac95b5 (diff) |
Add test case that panics on undo
This case panics since undo/redo call View::apply and here, the edit
that moves the jumplist selection out-of-bounds is not yet applied when
View::apply is called in undo/redo. View::apply should only be called
by the EditorView now.
Diffstat (limited to 'helix-term')
-rw-r--r-- | helix-term/tests/test/commands.rs | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/helix-term/tests/test/commands.rs b/helix-term/tests/test/commands.rs index 114bf222..27dbd9d7 100644 --- a/helix-term/tests/test/commands.rs +++ b/helix-term/tests/test/commands.rs @@ -283,3 +283,19 @@ async fn test_multi_selection_shell_commands() -> anyhow::Result<()> { Ok(()) } + +#[tokio::test(flavor = "multi_thread")] +async fn test_undo_redo() -> anyhow::Result<()> { + // A jumplist selection is passed through an edit and then an undo and then a redo. + // + // * [<space> Add a newline at line start. We're now on line 2. + // * <C-s> Save the selection on line 2 in the jumplist. + // * kd Delete line 1. The jumplist selection should be adjusted to the new line 1. + // * uU Undo and redo the `kd` edit. + // * <C-o> Jump back in the jumplist. This would panic if the jumplist were not being + // updated correctly. + // * <C-i> Jump forward to line 1. + test(("#[|]#", "[<space><C-s>kduU<C-o><C-i>", "#[|]#")).await?; + + Ok(()) +} |