From 4b8d4bfc055add6a42c88be1aa6a082de2cd7b42 Mon Sep 17 00:00:00 2001 From: Konstantin Pospelov Date: Sun, 15 Apr 2018 17:42:52 +0300 Subject: [PATCH] join: fix autoformat There was an issue with autoformat when the files had a different number of columns in the first line. This commit fixes the issue and extends the related test to cover this case. --- src/join/join.rs | 2 +- tests/fixtures/join/autoformat.expected | 10 +++++----- tests/fixtures/join/different_lengths.txt | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/join/join.rs b/src/join/join.rs index 67d92d7be..23761075f 100644 --- a/src/join/join.rs +++ b/src/join/join.rs @@ -327,7 +327,7 @@ impl<'a> State<'a> { } else { repr.print_field(key); repr.print_fields(&line1, self.key, self.max_fields); - repr.print_fields(&line2, other.key, self.max_fields); + repr.print_fields(&line2, other.key, other.max_fields); } println!(); diff --git a/tests/fixtures/join/autoformat.expected b/tests/fixtures/join/autoformat.expected index 576f91092..d1557e25b 100644 --- a/tests/fixtures/join/autoformat.expected +++ b/tests/fixtures/join/autoformat.expected @@ -1,5 +1,5 @@ -1 a a -2 b b -3 c d -4 d g -5 e i +1 a a b +2 b b c +3 c d e +4 d g h +5 e i diff --git a/tests/fixtures/join/different_lengths.txt b/tests/fixtures/join/different_lengths.txt index 3d4a53d78..0dfad2774 100644 --- a/tests/fixtures/join/different_lengths.txt +++ b/tests/fixtures/join/different_lengths.txt @@ -1,4 +1,4 @@ -1 a +1 a b 2 b c 3 d e f 4 g h