diff options
author | Mike Trinkala | 2024-03-03 17:55:09 +0000 |
---|---|---|
committer | GitHub | 2024-03-03 17:55:09 +0000 |
commit | 9267343830228490d379c90537ff1a6e4bba1260 (patch) | |
tree | fccee742245646ccae8ed94e589e157ac74c70cb /helix-term/tests/test/movement.rs | |
parent | 5bd007266a962a534bd722619821e998735b71e2 (diff) |
Fix panic when using surround_replace/delete (#9796)
1. Create a document containing `{A}`
1. C-w v # vsplit
1. gl # goto_line_end
1. b # move_prev_word_start
1. ` # switch_to_lowercase
1. mrm( # surround replace
1. C-w v # vsplit
In the debug build surround_replace/delete will immedately assert with
`assertion failed: last <= from', transaction.rs:597:13`. The splits and
lowercase conversion are not needed to trigger the bug.
In the release build the surround becomes `)a(` and the last vsplit
causes the transaction to panic.
`internal error: entered unreachable code:
(Some(Retain(18446744073709551573)))', transaction.rs:185:46`
Since the selection direction is backwards get_surround_pos returns the
pairs reversed but the downstream code assumes they are in the forward
direction.
Diffstat (limited to 'helix-term/tests/test/movement.rs')
-rw-r--r-- | helix-term/tests/test/movement.rs | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/helix-term/tests/test/movement.rs b/helix-term/tests/test/movement.rs index e3c2668d..0873edbe 100644 --- a/helix-term/tests/test/movement.rs +++ b/helix-term/tests/test/movement.rs @@ -552,3 +552,57 @@ async fn find_char_line_ending() -> anyhow::Result<()> { Ok(()) } + +#[tokio::test(flavor = "multi_thread")] +async fn test_surround_replace() -> anyhow::Result<()> { + test(( + platform_line(indoc! {"\ + (#[|a]#) + "}), + "mrm{", + platform_line(indoc! {"\ + {#[|a]#} + "}), + )) + .await?; + + test(( + platform_line(indoc! {"\ + (#[a|]#) + "}), + "mrm{", + platform_line(indoc! {"\ + {#[a|]#} + "}), + )) + .await?; + + Ok(()) +} + +#[tokio::test(flavor = "multi_thread")] +async fn test_surround_delete() -> anyhow::Result<()> { + test(( + platform_line(indoc! {"\ + (#[|a]#) + "}), + "mdm", + platform_line(indoc! {"\ + #[|a]# + "}), + )) + .await?; + + test(( + platform_line(indoc! {"\ + (#[a|]#) + "}), + "mdm", + platform_line(indoc! {"\ + #[a|]# + "}), + )) + .await?; + + Ok(()) +} |