From bfe398ca362bada151747e35a542fdd812c81b09 Mon Sep 17 00:00:00 2001 From: Douglas <32344964+NotTheDr01ds@users.noreply.github.com> Date: Sun, 9 Feb 2025 07:19:11 -0500 Subject: [PATCH] Fix `char lsep` assignment (#15065) Fix `char eol` issue where there was still a hardcoded `\n` taking effect on Windows. --- crates/nu-command/src/strings/char_.rs | 1 - crates/nu-command/tests/commands/platform/char_.rs | 10 ++++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/crates/nu-command/src/strings/char_.rs b/crates/nu-command/src/strings/char_.rs index b14ebd7b4f..6a0fe3d57a 100644 --- a/crates/nu-command/src/strings/char_.rs +++ b/crates/nu-command/src/strings/char_.rs @@ -69,7 +69,6 @@ static CHAR_MAP: LazyLock> = LazyLock::new(|| { "eol" => LINE_SEPARATOR_CHAR.to_string(), "lsep" => LINE_SEPARATOR_CHAR.to_string(), "line_sep" => LINE_SEPARATOR_CHAR.to_string(), - "lsep" => '\n'.to_string(), "esep" => ENV_PATH_SEPARATOR_CHAR.to_string(), "env_sep" => ENV_PATH_SEPARATOR_CHAR.to_string(), "tilde" => '~'.to_string(), // ~ diff --git a/crates/nu-command/tests/commands/platform/char_.rs b/crates/nu-command/tests/commands/platform/char_.rs index eeaffd4e4a..b51a6b06d5 100644 --- a/crates/nu-command/tests/commands/platform/char_.rs +++ b/crates/nu-command/tests/commands/platform/char_.rs @@ -10,3 +10,13 @@ fn test_char_list_outputs_table() { assert_eq!(actual.out, "113"); } + +#[test] +fn test_char_eol() { + let actual = nu!(r#" + let expected = if ($nu.os-info.name == 'windows') { "\r\n" } else { "\n" } + ((char lsep) == $expected) and ((char line_sep) == $expected) and ((char eol) == $expected) + "#); + + assert_eq!(actual.out, "true"); +}