From 305ca11eb57801ec491984f336294c3331e04903 Mon Sep 17 00:00:00 2001 From: Thomas Hartmann Date: Thu, 17 Oct 2019 09:40:00 +0200 Subject: [PATCH] Changes the parsing to use the full value of the final column. Previously it would split the last column on the first separator value found between the start of the column and the end of the row. Changing this to using everything from the start of the column to the end of the string makes it behave more similarly to the other columns, making it less surprising. --- src/commands/from_ssv.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/commands/from_ssv.rs b/src/commands/from_ssv.rs index 3af9e76084..913df9981a 100644 --- a/src/commands/from_ssv.rs +++ b/src/commands/from_ssv.rs @@ -75,7 +75,7 @@ fn string_to_table( .filter_map(|(i, (start, col))| { (match columns.get(i + 1) { Some((end, _)) => l.get(*start..*end), - None => l.get(*start..)?.split(&separator).next(), + None => l.get(*start..), }) .and_then(|s| Some((col.clone(), String::from(s.trim())))) }) @@ -298,16 +298,16 @@ mod tests { } #[test] - fn it_drops_trailing_values() { + fn it_uses_the_full_final_column() { let input = r#" colA col B - val1 val2 trailing value that should be ignored + val1 val2 trailing value that should be included "#; let result = string_to_table(input, false, 2).unwrap(); assert_eq!( result, - vec![vec![owned("colA", "val1"), owned("col B", "val2"),],] + vec![vec![owned("colA", "val1"), owned("col B", "val2 trailing value that should be included"),],] ) } }