From 453a4864c506eefc777cbdb98c993d549ac65efe Mon Sep 17 00:00:00 2001 From: Em Zhan Date: Mon, 11 Sep 2023 17:47:40 -0500 Subject: [PATCH] Add test for `insert-final-newline` set to false --- helix-term/tests/test/commands/write.rs | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/helix-term/tests/test/commands/write.rs b/helix-term/tests/test/commands/write.rs index de93a95d0444..376ba5e7b1e7 100644 --- a/helix-term/tests/test/commands/write.rs +++ b/helix-term/tests/test/commands/write.rs @@ -460,6 +460,31 @@ async fn test_write_insert_final_newline_unchanged_if_not_missing() -> anyhow::R Ok(()) } +#[tokio::test(flavor = "multi_thread")] +async fn test_write_insert_final_newline_unchanged_if_missing_and_false() -> anyhow::Result<()> { + let mut file = tempfile::NamedTempFile::new()?; + let mut app = helpers::AppBuilder::new() + .with_config(Config { + editor: helix_view::editor::Config { + insert_final_newline: false, + ..Default::default() + }, + ..Default::default() + }) + .with_file(file.path(), None) + .with_input_text("#[t|]#he quiet rain continued through the night") + .build()?; + + test_key_sequence(&mut app, Some(":w"), None, false).await?; + + helpers::assert_file_has_content( + file.as_file_mut(), + "the quiet rain continued through the night", + )?; + + Ok(()) +} + #[tokio::test(flavor = "multi_thread")] async fn test_write_all_insert_final_newline_add_if_missing_and_modified() -> anyhow::Result<()> { let mut file1 = tempfile::NamedTempFile::new()?;