From 58ea1930544df165a4a1342932e4dd8cb93e14ea Mon Sep 17 00:00:00 2001 From: Skyler Hawthorne Date: Sat, 17 Sep 2022 09:34:56 -0400 Subject: Allow explicit newlines in test DSL The current test DSL currently has no way to express being at the end of a line, save for putting an explicit LF or CRLF inside the `#[|]#`. The problem with this approach is that it can add unintended extra new lines if used in conjunction with raw strings, which insert newlines for you. This is a simple attempt to mitigate this problem. If there is an explicit newline character at the end of the selection, and then it is immediately followed by the same newline character at the right end of the selection, this following newline is removed. This way, one can express a cursor at the end of a line explicitly. --- helix-term/tests/test/commands.rs | 44 +++++++++++++++++++-------------------- 1 file changed, 22 insertions(+), 22 deletions(-) (limited to 'helix-term/tests') diff --git a/helix-term/tests/test/commands.rs b/helix-term/tests/test/commands.rs index 74c32c4a..342a849b 100644 --- a/helix-term/tests/test/commands.rs +++ b/helix-term/tests/test/commands.rs @@ -201,12 +201,12 @@ async fn test_multi_selection_shell_commands() -> anyhow::Result<()> { .as_str(), "|echo foo", platform_line(indoc! {"\ - #[|foo - ]# - #(|foo - )# - #(|foo - )# + #[|foo\n]# + + #(|foo\n)# + + #(|foo\n)# + "}) .as_str(), )) @@ -222,12 +222,12 @@ async fn test_multi_selection_shell_commands() -> anyhow::Result<()> { .as_str(), "!echo foo", platform_line(indoc! {"\ - #[|foo - ]#lorem - #(|foo - )#ipsum - #(|foo - )#dolor + #[|foo\n]# + lorem + #(|foo\n)# + ipsum + #(|foo\n)# + dolor "}) .as_str(), )) @@ -243,12 +243,12 @@ async fn test_multi_selection_shell_commands() -> anyhow::Result<()> { .as_str(), "echo foo", platform_line(indoc! {"\ - lorem#[|foo - ]# - ipsum#(|foo - )# - dolor#(|foo - )# + lorem#[|foo\n]# + + ipsum#(|foo\n)# + + dolor#(|foo\n)# + "}) .as_str(), )) @@ -300,8 +300,8 @@ async fn test_extend_line() -> anyhow::Result<()> { platform_line(indoc! {"\ #[lorem ipsum - dolor - |]# + dolor\n|]# + "}) .as_str(), )) @@ -318,8 +318,8 @@ async fn test_extend_line() -> anyhow::Result<()> { "2x", platform_line(indoc! {"\ #[lorem - ipsum - |]# + ipsum\n|]# + "}) .as_str(), )) -- cgit v1.2.3-70-g09d2