mirror of
https://github.com/junegunn/fzf.git
synced 2025-11-17 15:53:39 -05:00
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
This commit is contained in:
@@ -7,6 +7,7 @@ import (
|
||||
// Item represents each input line
|
||||
type Item struct {
|
||||
index int32
|
||||
trimLength int32
|
||||
text util.Chars
|
||||
origText *[]byte
|
||||
colors *[]ansiOffset
|
||||
@@ -18,6 +19,14 @@ func (item *Item) Index() int32 {
|
||||
return item.index
|
||||
}
|
||||
|
||||
func (item *Item) TrimLength() int32 {
|
||||
if item.trimLength >= 0 {
|
||||
return item.trimLength
|
||||
}
|
||||
item.trimLength = int32(item.text.TrimLength())
|
||||
return item.trimLength
|
||||
}
|
||||
|
||||
// Colors returns ansiOffsets of the Item
|
||||
func (item *Item) Colors() []ansiOffset {
|
||||
if item.colors == nil {
|
||||
|
||||
Reference in New Issue
Block a user