mirror of
https://github.com/nushell/nushell
synced 2024-12-27 05:23:11 +00:00
- Fixes #11997 # Description Fixes the issue that comments are not ignored in SSV formatted data. ![Fix image](https://github.com/nushell/nushell/assets/64328283/1c1bd7dd-ced8-4276-8c21-b50e1c0dba53) # User-Facing Changes If you have a comment in the beginning of SSV formatted data it is now not included in the SSV table. # Tests + Formatting The PR adds one test in the ssv.rs file. All previous test-cases are still passing. Clippy and Fmt have been ran.
This commit is contained in:
parent
262914cf92
commit
39cf43ef06
1 changed files with 21 additions and 1 deletions
|
@ -239,7 +239,9 @@ fn string_to_table(
|
|||
aligned_columns: bool,
|
||||
split_at: usize,
|
||||
) -> Vec<Vec<(String, String)>> {
|
||||
let mut lines = s.lines().filter(|l| !l.trim().is_empty());
|
||||
let mut lines = s
|
||||
.lines()
|
||||
.filter(|l| !l.trim().is_empty() && !l.trim().starts_with('#'));
|
||||
let separator = " ".repeat(std::cmp::max(split_at, 1));
|
||||
|
||||
let (ls, header_options) = if noheaders {
|
||||
|
@ -314,6 +316,24 @@ mod tests {
|
|||
(String::from(x), String::from(y))
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn it_filters_comment_lines() {
|
||||
let input = r#"
|
||||
a b
|
||||
1 2
|
||||
3 4
|
||||
#comment line
|
||||
"#;
|
||||
let result = string_to_table(input, false, true, 1);
|
||||
assert_eq!(
|
||||
result,
|
||||
vec![
|
||||
vec![owned("a", "1"), owned("b", "2")],
|
||||
vec![owned("a", "3"), owned("b", "4")]
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn it_trims_empty_and_whitespace_only_lines() {
|
||||
let input = r#"
|
||||
|
|
Loading…
Reference in a new issue