Fix char lsep assignment (#15065)

Fix `char eol` issue where there was still a hardcoded `\n` taking
effect on Windows.
This commit is contained in:
Douglas 2025-02-09 07:19:11 -05:00 committed by GitHub
parent 31e1f49cb6
commit bfe398ca36
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 10 additions and 1 deletions

View File

@ -69,7 +69,6 @@ static CHAR_MAP: LazyLock<IndexMap<&'static str, String>> = LazyLock::new(|| {
"eol" => LINE_SEPARATOR_CHAR.to_string(), "eol" => LINE_SEPARATOR_CHAR.to_string(),
"lsep" => LINE_SEPARATOR_CHAR.to_string(), "lsep" => LINE_SEPARATOR_CHAR.to_string(),
"line_sep" => LINE_SEPARATOR_CHAR.to_string(), "line_sep" => LINE_SEPARATOR_CHAR.to_string(),
"lsep" => '\n'.to_string(),
"esep" => ENV_PATH_SEPARATOR_CHAR.to_string(), "esep" => ENV_PATH_SEPARATOR_CHAR.to_string(),
"env_sep" => ENV_PATH_SEPARATOR_CHAR.to_string(), "env_sep" => ENV_PATH_SEPARATOR_CHAR.to_string(),
"tilde" => '~'.to_string(), // ~ "tilde" => '~'.to_string(), // ~

View File

@ -10,3 +10,13 @@ fn test_char_list_outputs_table() {
assert_eq!(actual.out, "113"); 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");
}