Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'helix-term/tests/test/commands/write.rs')
| -rw-r--r-- | helix-term/tests/test/commands/write.rs | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/helix-term/tests/test/commands/write.rs b/helix-term/tests/test/commands/write.rs index aba101e9..38ab643c 100644 --- a/helix-term/tests/test/commands/write.rs +++ b/helix-term/tests/test/commands/write.rs @@ -421,6 +421,50 @@ async fn test_write_utf_bom_file() -> anyhow::Result<()> { } #[tokio::test(flavor = "multi_thread")] +async fn test_write_trim_trailing_whitespace() -> anyhow::Result<()> { + let mut file = tempfile::NamedTempFile::new()?; + let mut app = helpers::AppBuilder::new() + .with_config(Config { + editor: helix_view::editor::Config { + trim_trailing_whitespace: true, + ..Default::default() + }, + ..Default::default() + }) + .with_file(file.path(), None) + .with_input_text("#[f|]#oo \n\n \nbar ") + .build()?; + + test_key_sequence(&mut app, Some(":w<ret>"), None, false).await?; + + helpers::assert_file_has_content(&mut file, &LineFeedHandling::Native.apply("foo\n\n\nbar"))?; + + Ok(()) +} + +#[tokio::test(flavor = "multi_thread")] +async fn test_write_trim_final_newlines() -> anyhow::Result<()> { + let mut file = tempfile::NamedTempFile::new()?; + let mut app = helpers::AppBuilder::new() + .with_config(Config { + editor: helix_view::editor::Config { + trim_final_newlines: true, + ..Default::default() + }, + ..Default::default() + }) + .with_file(file.path(), None) + .with_input_text("#[f|]#oo\n \n\n\n") + .build()?; + + test_key_sequence(&mut app, Some(":w<ret>"), None, false).await?; + + helpers::assert_file_has_content(&mut file, &LineFeedHandling::Native.apply("foo\n \n"))?; + + Ok(()) +} + +#[tokio::test(flavor = "multi_thread")] async fn test_write_insert_final_newline_added_if_missing() -> anyhow::Result<()> { let mut file = tempfile::NamedTempFile::new()?; let mut app = helpers::AppBuilder::new() |