Handle mixed LF+CRLF in lines (#7316)

This closes #4989. Previously `lines` was unable to handle text input
with CRLF line breaks _and_ LF line breaks.

### Before:

![image](https://user-images.githubusercontent.com/26268125/205207685-b25da9e1-19fa-4abb-8ab2-0dd216c63fc0.png)

### After:


![image](https://user-images.githubusercontent.com/26268125/205207808-9f687242-a8c2-4b79-a12c-38b0583d8d52.png)
This commit is contained in:
Reilly Wood
2022-12-02 08:30:26 -08:00
committed by GitHub
parent 3ac36879e0
commit ee5a387300
4 changed files with 32 additions and 17 deletions

View File

@ -48,3 +48,16 @@ fn lines_multi_value_split() {
assert_eq!(actual.out, "6");
}
/// test whether this handles CRLF and LF in the same input
#[test]
fn lines_mixed_line_endings() {
let actual = nu!(
cwd: "tests/fixtures/formats", pipeline(
r#"
"foo\nbar\r\nquux" | lines | length
"#
));
assert_eq!(actual.out, "3");
}