on master help sign in
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.

commit94eb3de7767c5d16344bec9634028f346cd867bb authorMichael Davis <mcarsondavis@gmail.com> dateWed 23 Nov 2022, 08:57 (4 years ago) parent590a628
1 file changed+16
helix-term/tests/test/commands.rs+16
helix-term/tests/test/commands.rs+16
@@ -283,3 +283,19 @@ async fn test_multi_selection_shell_commands() -> anyhow::Result<()> {
283283
284284 Ok(())
285285}
286+
287+#[tokio::test(flavor = "multi_thread")]
288+async fn test_undo_redo() -> anyhow::Result<()> {
289+ // A jumplist selection is passed through an edit and then an undo and then a redo.
290+ //
291+ // * [<space> Add a newline at line start. We're now on line 2.
292+ // * <C-s> Save the selection on line 2 in the jumplist.
293+ // * kd Delete line 1. The jumplist selection should be adjusted to the new line 1.
294+ // * uU Undo and redo the `kd` edit.
295+ // * <C-o> Jump back in the jumplist. This would panic if the jumplist were not being
296+ // updated correctly.
297+ // * <C-i> Jump forward to line 1.
298+ test(("#[|]#", "[<space><C-s>kduU<C-o><C-i>", "#[|]#")).await?;
299+
300+ Ok(())
301+}