Skip to content
Myr

Ignore leading whitespaces when calculating 'begin' index

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 23244bb · Browse files · 3 files+68 added−2 removed
This commit

State

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

Diff stats

3 files+68 added−2 removed

  • tests:+58 added−0 removed
  • other:+10 added−2 removed

3 files+68 added−2 removed

modified:src/item.go+8 added-1 removed
90 unmodified lines
91 val = int32(len(item.text))92 }93 case byBegin:94 // We can't just look at item.offsets[0][0] because it can be an inverse term95 whitePrefixLen := 096 for idx, r := range item.text {97 whitePrefixLen = idx98 if idx == minBegin || r != ' ' && r != '\t' {99 break100 }101 }95 val = int32(minBegin)102 val = int32(minBegin - whitePrefixLen)103 case byEnd:104 if prevEnd > 0 {105 val = int32(1 + len(item.text) - prevEnd)106 } else {
182 unmodified lines
modified:test/test_go.rb+58 added
603 unmodified lines
604 assert_equal by_begin_end, `#{FZF} -ffb --tiebreak=end,begin < #{tempname}`.split($/)605 assert_equal by_begin_end, `#{FZF} -ffb --tiebreak=end,length < #{tempname}`.split($/)606 end607608 def test_tiebreak_white_prefix609 writelines tempname, [610 'f o o b a r',611 ' foo bar',612 ' foobar',613 '----foo bar',614 '----foobar',615 ' foo bar',616 ' foobar--',617 ' foobar',618 '--foo bar',619 '--foobar',620 'foobar',621 ]622623 assert_equal [624 ' foobar',625 ' foobar',626 'foobar',627 ' foobar--',628 '--foobar',629 '----foobar',630 ' foo bar',631 ' foo bar',632 '--foo bar',633 '----foo bar',634 'f o o b a r',635 ], `#{FZF} -ffb < #{tempname}`.split($/)636637 assert_equal [638 ' foobar',639 ' foobar--',640 ' foobar',641 'foobar',642 '--foobar',643 '----foobar',644 ' foo bar',645 ' foo bar',646 '--foo bar',647 '----foo bar',648 'f o o b a r',649 ], `#{FZF} -ffb --tiebreak=begin < #{tempname}`.split($/)650651 assert_equal [652 ' foobar',653 ' foobar',654 'foobar',655 ' foobar--',656 '--foobar',657 '----foobar',658 ' foo bar',659 ' foo bar',660 '--foo bar',661 '----foo bar',662 'f o o b a r',663 ], `#{FZF} -ffb --tiebreak=begin,length < #{tempname}`.split($/)664 end665666 def test_tiebreak_length_with_nth667 input = %w[668 1:hell669 123:hello
729 unmodified lines
modified:CHANGELOG.md+2 added-1 removed
2 unmodified lines
340.11.25------67- `--tiebreak` now accepts comma-separated list of sort criteria.7- `--tiebreak` now accepts comma-separated list of sort criteria8 - Each criterion should appear only once in the list9 - `index` is only allowed at the end of the list10 - `index` is implicitly appended to the list when not specified11 - Default is `length` (or equivalently `length,index`)12- `begin` criterion will ignore leading whitespaces when calculating the index13140.11.115------16
336 unmodified lines