Skip to content
Myr

Only consider the lengths of the relevant parts when --nth is set

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Junegunn Choi · committed by Junegunn Choi · parent 5e90f0a · Browse files · 2 files+36 added−1 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

2 files+36 added−1 removed

  • tests:+26 added−0 removed
  • other:+10 added−1 removed

2 files+36 added−1 removed

modified:src/item.go+10 added-1 removed
61 unmodified lines
62 }63 var tiebreak uint1664 switch rankTiebreak {65 case byLength:66 // It is guaranteed that .transformed in not null in normal execution67 if i.transformed != nil {68 lenSum := 069 for _, token := range *i.transformed {70 lenSum += len(*token.text)71 }72 tiebreak = uint16(lenSum)73 } else {66 tiebreak = uint16(len(*i.text))74 tiebreak = uint16(len(*i.text))75 }76 case byBegin:77 // We can't just look at i.offsets[0][0] because it can be an inverse term78 tiebreak = uint16(minBegin)79 case byEnd:
182 unmodified lines
modified:test/test_go.rb+26 added
499 unmodified lines
500501 assert_equal input, `cat #{tempname} | #{FZF} -f"!z" -x --tiebreak end`.split($/)502 end503504 def test_tiebreak_length_with_nth505 input = %w[506 1:hell507 123:hello508 12345:he509 1234567:h510 ]511 writelines tempname, input512513 output = %w[514 1:hell515 12345:he516 123:hello517 1234567:h518 ]519 assert_equal output, `cat #{tempname} | #{FZF} -fh`.split($/)520521 output = %w[522 1234567:h523 12345:he524 1:hell525 123:hello526 ]527 assert_equal output, `cat #{tempname} | #{FZF} -fh -n2 -d:`.split($/)528 end529530 def test_invalid_cache531 tmux.send_keys "(echo d; echo D; echo x) | #{fzf '-q d'}", :Enter532 tmux.until { |lines| lines[-2].include? '2/3' }533 tmux.send_keys :BSpace
484 unmodified lines