diff --git a/helix-term/tests/test/commands.rs b/helix-term/tests/test/commands.rs index 52b123c7eb58..b13c37bcdcb6 100644 --- a/helix-term/tests/test/commands.rs +++ b/helix-term/tests/test/commands.rs @@ -426,3 +426,56 @@ async fn test_delete_char_forward() -> anyhow::Result<()> { Ok(()) } + +#[tokio::test(flavor = "multi_thread")] +async fn test_insert_with_indent() -> anyhow::Result<()> { + const INPUT: &str = "\ +#[f|]#n foo() { + if let Some(_) = None { + + } +\x20 +} + +fn bar() { + +}"; + + // insert_at_line_start + test(( + INPUT, + ":lang rust%I", + "\ +#[f|]#n foo() { + #(i|)#f let Some(_) = None { + #(\n|)#\ +\x20 #(}|)# +#(\x20|)# +#(}|)# +#(\n|)#\ +#(f|)#n bar() { + #(\n|)#\ +#(}|)#", + )) + .await?; + + // insert_at_line_end + test(( + INPUT, + ":lang rust%A", + "\ +fn foo() {#[\n|]#\ +\x20 if let Some(_) = None {#(\n|)#\ +\x20 #(\n|)#\ +\x20 }#(\n|)#\ +\x20#(\n|)#\ +}#(\n|)#\ +#(\n|)#\ +fn bar() {#(\n|)#\ +\x20 #(\n|)#\ +}#(|)#", + )) + .await?; + + Ok(()) +}