Add 'multi' event triggered on multi-selection changes
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 d7db7fc · Browse files · 6 files·+31 added−4 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+31 added−4 removed
- tests:+11 added−0 removed
- other:+20 added−4 removed
Provenance
- Commit
6e3c830- Tree
7a944ed- Author
Junegunn Choi <junegunn.c@gmail.com>- Committer
Junegunn Choi <junegunn.c@gmail.com>- Parent
d7db7fc
6 files changed+31 added−4 removed
modified:man/man1/fzf.1+6 added-2 removed
19 unmodified lines20 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,21 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN22 THE SOFTWARE.23 ..24-.TH fzf 1 "Jun 2025" "fzf 0.63.0" "fzf - a command-line fuzzy finder"24+.TH fzf 1 "Jul 2025" "fzf 0.64.0" "fzf - a command-line fuzzy finder"25 26 .SH NAME27 fzf - a command-line fuzzy finder28 1579 unmodified lines1608 1609 # Beware not to introduce an infinite loop1610 seq 10 | fzf \-\-bind 'focus:up' \-\-cycle\fR1611 .RE1612+\fImulti\fR1613+.RS1614+Triggered when the multi\-selection has changed.1615+.RE1616 1617 \fIone\fR1618 .RS1619 Triggered when there's only one match. \fBone:accept\fR binding is comparable94 unmodified lines1714 \fBchange\-preview\-window(...)\fR (change \fB\-\-preview\-window\fR option; rotate through the multiple option sets separated by '|')1715 \fBchange\-prompt(...)\fR (change prompt to the given string)1716 \fBchange\-query(...)\fR (change query string to the given string)1717 \fBclear\-screen\fR \fIctrl\-l\fR1714- \fBclear\-selection\fR (clear multi\-selection)1718+ \fBclear\-multi\fR (clear multi\-selection)1719 \fBclose\fR (close preview window if open, abort fzf otherwise)1720 \fBclear\-query\fR (clear query string)1721 \fBdelete\-char\fR \fIdel\fR1722 \fBdelete\-char/eof\fR \fIctrl\-d\fR (same as \fBdelete\-char\fR except aborts fzf if query is empty)292 unmodified linesmodified:src/tui/tui.go+1 added
130 unmodified lines131 Result132 Jump133 JumpCancel134 ClickHeader135+ Multi136 )137 138 func (t EventType) AsEvent() Event {139 return Event{t, 0, nil}1013 unmodified linesmodified:src/options.go+3 added-1 removed
1006 unmodified lines1007 case "jump-cancel":1008 add(tui.JumpCancel)1009 case "click-header":1010 add(tui.ClickHeader)1011+ case "multi":1012+ add(tui.Multi)1013 case "alt-enter", "alt-return":1014 chords[tui.CtrlAltKey('m')] = key1015 case "alt-space":1016 chords[tui.AltKey(' ')] = key545 unmodified lines1562 case "cancel":1563 appendAction(actCancel)1564 case "clear-query":1565 appendAction(actClearQuery)1564- case "clear-selection":1566+ case "clear-multi", "clear-selection":1567 appendAction(actClearSelection)1568 case "forward-char":1569 appendAction(actForwardChar)1570 case "forward-word":2046 unmodified linesmodified:src/terminal.go+4 added
5397 unmodified lines5398 }5399 }5400 previousInput := t.input5401 previousCx := t.cx5402+ previousVersion := t.version5403 t.lastKey = event.KeyName()5404 updatePreviewWindow := func(forcePreview bool) {5405 t.resizeWindows(forcePreview, false)5406 req(reqPrompt, reqList, reqInfo, reqHeader, reqFooter)1249 unmodified lines6656 }6657 if onEOFs, prs := t.keymap[tui.BackwardEOF.AsEvent()]; beof && prs && !doActions(onEOFs) {6658 continue6659 }6660+ if onMultis, prs := t.keymap[tui.Multi.AsEvent()]; t.version != previousVersion && prs && !doActions(onMultis) {6661+ continue6662+ }6663 } else {6664 jumpEvent := tui.JumpCancel6665 if event.Type == tui.Rune {6666 if idx := strings.IndexRune(t.jumpLabels, event.Char); idx >= 0 && idx < t.maxItems() && idx < t.merger.Length() {259 unmodified linesmodified:test/test_core.rb+11 added
1986 unmodified lines1987 tmux.until { assert_equal 100, it.match_count }1988 tmux.until { assert it.any_include?('boom') }1989 tmux.until { assert it.any_include?('bam') }1990 end1991+1992+ def test_multi_event1993+ tmux.send_keys %(seq 100 | #{FZF} --multi --bind 'multi:transform-footer:(( FZF_SELECT_COUNT )) && echo "Selected $FZF_SELECT_COUNT item(s)"'), :Enter1994+ tmux.until { assert_equal 100, it.match_count }1995+ tmux.send_keys :Tab1996+ tmux.until { assert_equal 1, it.select_count }1997+ tmux.until { assert it.any_include?('Selected 1 item(s)') }1998+ tmux.send_keys :Tab1999+ tmux.until { assert_equal 0, it.select_count }2000+ tmux.until { refute it.any_include?('Selected') }2001+ end2002 endmodified:CHANGELOG.md+6 added-1 removed
1 CHANGELOG2 =========3 4-0.63.14+0.64.05 ------6+- Added `multi` event that is triggered when the multi-selection has changed.7+ ```sh8+ fzf --multi --bind 'multi:transform-footer:(( FZF_SELECT_COUNT )) && echo "Selected: $FZF_SELECT_COUNT item(s)"'9+ ```10 - [Halfwidth and fullwidth alphanumeric and punctuation characters](https://en.wikipedia.org/wiki/Halfwidth_and_Fullwidth_Forms_(Unicode_block)) are now internally normalized to their ASCII equivalents to allow matching with ASCII queries.11 ```sh12 echo ABC| fzf -q abc13 ```14 - Fixed a bug which caused fzf to abort due to incorrect update ordering.15+- Renamed `clear-selection` action to `clear-multi` for consistency.16 17 0.63.018 ------19 _Release highlights: https://junegunn.github.io/fzf/releases/0.63.0/_2715 unmodified lines