Skip to content
Myr

Add 'one' event

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

Close #2629 Close #2494 Close #459

authored by Junegunn Choi · committed by Junegunn Choi · parent 1c7534f · Browse files · 6 files+39 added−0 removed
This commit

State

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

Diff stats

6 files+39 added−0 removed

  • tests:+14 added−0 removed
  • other:+25 added−0 removed

6 files+39 added−0 removed

modified:man/man1/fzf.1+11 added
991 unmodified lines
992993 # Beware not to introduce an infinite loop994 seq 10 | fzf --bind 'focus:up' --cycle\fR995.RE996\fIone\fR997.RS998Triggered when there's only one match. \fBone:accept\fR binding is comparable999to \fB--select-1\fR option, but the difference is that \fB--select-1\fR is only1000effective before the interactive finder starts but \fBone\fR event is triggered1001by the interactive finder.10021003e.g.1004 \fB# Automatically select the only match1005 seq 10 | fzf --bind one:accept\fR1006.RE10071008\fIbackward-eof\fR1009.RS1010Triggered when the query string is already empty and you try to delete it1011backward.
251 unmodified lines
modified:src/tui/tui.go+1 added
91 unmodified lines
92 BackwardEOF93 Start94 Load95 Focus96 One9798 AltBS99100 AltUp
614 unmodified lines
modified:src/options.go+2 added
620 unmodified lines
621 case "load":622 add(tui.Load)623 case "focus":624 add(tui.Focus)625 case "one":626 add(tui.One)627 case "alt-enter", "alt-return":628 chords[tui.CtrlAltKey('m')] = key629 case "alt-space":630 chords[tui.AltKey(' ')] = key
1433 unmodified lines
modified:src/terminal.go+6 added
930 unmodified lines
931 // Try to keep the vertical position when the list shrinks932 t.cy = count - util.Min(count, t.maxItems()) + pos933 }934 }935 if !t.reading && t.merger.Length() == 1 {936 one := tui.One.AsEvent()937 if _, prs := t.keymap[one]; prs {938 t.eventChan <- one939 }940 }941 t.mutex.Unlock()942 t.reqBox.Set(reqInfo, nil)943 t.reqBox.Set(reqList, nil)944}
2680 unmodified lines
modified:test/test_go.rb+14 added
2700 unmodified lines
2701 assert_equal 1000, lines.match_count2702 assert_equal '> 555', lines[index]2703 end2704 end27052706 def test_one2707 tmux.send_keys "seq 10 | #{FZF} --bind 'one:preview:echo {} is the only match'", :Enter2708 tmux.send_keys '1'2709 tmux.until do |lines|2710 assert_equal 2, lines.match_count2711 refute lines.any? { _1.include?('only match') }2712 end2713 tmux.send_keys '0'2714 tmux.until do |lines|2715 assert_equal 1, lines.match_count2716 assert lines.any? { _1.include?('only match') }2717 end2718 end2719end27202721module TestShell2722 def setup
481 unmodified lines
modified:CHANGELOG.md+5 added
1 unmodified line
2=========340.39.05------6- Added `one` event that is triggered when there's only one match7 ```sh8 # Automatically select the only match9 seq 10 | fzf --bind one:accept10 ```11- Added `--track` option that makes fzf track the current selection when the12 result list is updated. This can be useful when browsing logs using fzf with13 sorting disabled.14 ```sh
1586 unmodified lines