From 4a103db6228ba54e0f36bbebb95d25867458f473 Mon Sep 17 00:00:00 2001 From: Michael Davis Date: Wed, 23 Nov 2022 09:35:07 -0600 Subject: Apply inversions to Views on undo/redo When using undo/redo, the history revision can be decremented. In that case we should apply the inversions since the given revision in History::changes_since. This prevents panics with jumplist operations when a session uses undo/redo to move the jumplist selection outside of the document. --- helix-term/tests/test/commands.rs | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'helix-term/tests') diff --git a/helix-term/tests/test/commands.rs b/helix-term/tests/test/commands.rs index 27dbd9d7..01295704 100644 --- a/helix-term/tests/test/commands.rs +++ b/helix-term/tests/test/commands.rs @@ -286,6 +286,15 @@ async fn test_multi_selection_shell_commands() -> anyhow::Result<()> { #[tokio::test(flavor = "multi_thread")] async fn test_undo_redo() -> anyhow::Result<()> { + // A jumplist selection is created at a point which is undone. + // + // * 2[ Add two newlines at line start. We're now on line 3. + // * Save the selection on line 3 in the jumplist. + // * u Undo the two newlines. We're now on line 1. + // * Jump forward an back again in the jumplist. This would panic + // if the jumplist were not being updated correctly. + test(("#[|]#", "2[u", "#[|]#")).await?; + // A jumplist selection is passed through an edit and then an undo and then a redo. // // * [ Add a newline at line start. We're now on line 2. -- cgit v1.2.3-70-g09d2