From 2e3dc75425d23b4d9e8e05a901395914cf8d3120 Mon Sep 17 00:00:00 2001 From: Junegunn Choi Date: Fri, 2 Jun 2017 13:25:35 +0900 Subject: Fix inconsistent tiebreak scores when --nth is used Make sure to consistently calculate tiebreak scores based on the original line. This change may not be preferable if you filter aligned tabular input on a subset of columns using --nth. However, if we calculate length tiebreak only on the matched components instead of the entire line, the result can be very confusing when multiple --nth components are specified, so let's keep it simple and consistent. Close #926 --- src/tokenizer.go | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'src/tokenizer.go') diff --git a/src/tokenizer.go b/src/tokenizer.go index ed873622..0e216ac7 100644 --- a/src/tokenizer.go +++ b/src/tokenizer.go @@ -20,7 +20,6 @@ type Range struct { type Token struct { text *util.Chars prefixLength int32 - trimLength int32 } // Delimiter for tokenizing the input @@ -81,7 +80,7 @@ func withPrefixLengths(tokens []util.Chars, begin int) []Token { prefixLength := begin for idx, token := range tokens { // NOTE: &tokens[idx] instead of &tokens - ret[idx] = Token{&tokens[idx], int32(prefixLength), int32(token.TrimLength())} + ret[idx] = Token{&tokens[idx], int32(prefixLength)} prefixLength += token.Length() } return ret @@ -242,7 +241,7 @@ func Transform(tokens []Token, withNth []Range) []Token { } else { prefixLength = 0 } - transTokens[idx] = Token{&merged, prefixLength, int32(merged.TrimLength())} + transTokens[idx] = Token{&merged, prefixLength} } return transTokens } -- cgit v1.2.3