diff --git a/helix-term/tests/test/commands/variable_expansion.rs b/helix-term/tests/test/commands/variable_expansion.rs index 1d644cb6c..61580d7e4 100644 --- a/helix-term/tests/test/commands/variable_expansion.rs +++ b/helix-term/tests/test/commands/variable_expansion.rs @@ -1,5 +1,5 @@ use super::*; - +use std::borrow::Cow; #[tokio::test(flavor = "multi_thread")] async fn test_variable_expansion() -> anyhow::Result<()> { { @@ -19,8 +19,6 @@ async fn test_variable_expansion() -> anyhow::Result<()> { .await?; let mut app = AppBuilder::new().build()?; - let mut app = AppBuilder::new().build()?; - test_key_sequence( &mut app, Some(":echo %{basename}"), @@ -128,6 +126,57 @@ async fn test_variable_expansion() -> anyhow::Result<()> { false, ) .await?; + + let mut app = AppBuilder::new().build()?; + + test_key_sequence( + &mut app, + Some(":echo %sh{echo %{filename}}"), + Some(&|app| { + assert_eq!( + app.editor.get_status().unwrap().0, + helix_view::document::SCRATCH_BUFFER_NAME + ); + }), + false, + ) + .await?; + let mut app = AppBuilder::new().build()?; + + test_key_sequence( + &mut app, + Some(":echo %sh{echo %{filename} %{linenumber}}"), + Some(&|app| { + assert_eq!( + app.editor.get_status().unwrap().0, + &Cow::from(format!( + "{} {}", + helix_view::document::SCRATCH_BUFFER_NAME, + 1 + )) + ); + }), + false, + ) + .await?; + let mut app = AppBuilder::new().build()?; + + test_key_sequence( + &mut app, + Some(":echo %sh{echo %{filename} %sh{echo %{filename}}}"), + Some(&|app| { + assert_eq!( + app.editor.get_status().unwrap().0, + &Cow::from(format!( + "{} {}", + helix_view::document::SCRATCH_BUFFER_NAME, + helix_view::document::SCRATCH_BUFFER_NAME + )) + ); + }), + false, + ) + .await?; } Ok(())