Skip to content
Myr

Add select and deselect actions

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

Close #2358

authored by Junegunn Choi · committed by Junegunn Choi · parent 806a47a · Browse files · 5 files+60 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

5 files+60 added−0 removed

  • tests:+21 added−0 removed
  • other:+39 added−0 removed

5 files+60 added−0 removed

modified:man/man1/fzf.1+2 added
782 unmodified lines
783 \fBclose\fR (close preview window if open, abort fzf otherwise)784 \fBclear-query\fR (clear query string)785 \fBdelete-char\fR \fIdel\fR786 \fBdelete-char/eof\fR \fIctrl-d\fR (same as \fBdelete-char\fR except aborts fzf if query is empty)787 \fBdeselect\fR788 \fBdeselect-all\fR (deselect all matches)789 \fBdisable-search\fR (disable search functionality)790 \fBdown\fR \fIctrl-j ctrl-n down\fR791 \fBenable-search\fR (enable search functionality)
27 unmodified lines
819 \fBprint-query\fR (print query and exit)820 \fBrefresh-preview\fR821 \fBreload(...)\fR (see below for the details)822 \fBreplace-query\fR (replace query string with the current selection)823 \fBselect\fR824 \fBselect-all\fR (select all matches)825 \fBtoggle\fR (\fIright-click\fR)826 \fBtoggle-all\fR (toggle all matches)827 \fBtoggle+down\fR \fIctrl-i (tab)\fR
129 unmodified lines
modified:src/options.go+4 added
837 unmodified lines
838 case "delete-char":839 appendAction(actDeleteChar)840 case "delete-char/eof":841 appendAction(actDeleteCharEOF)842 case "deselect":843 appendAction(actDeselect)844 case "end-of-line":845 appendAction(actEndOfLine)846 case "cancel":847 appendAction(actCancel)
32 unmodified lines
880 case "toggle-all":881 appendAction(actToggleAll)882 case "toggle-search":883 appendAction(actToggleSearch)884 case "select":885 appendAction(actSelect)886 case "select-all":887 appendAction(actSelectAll)888 case "deselect-all":889 appendAction(actDeselectAll)
716 unmodified lines
modified:src/terminal.go+27 added
274 unmodified lines
275 actLast276 actReload277 actDisableSearch278 actEnableSearch279 actSelect280 actDeselect281)282283type placeholderFlags struct {284 plus bool
1501 unmodified lines
17861787 return true1788}17891790func (t *Terminal) selectItemChanged(item *Item) bool {1791 if _, found := t.selected[item.Index()]; found {1792 return false1793 }1794 return t.selectItem(item)1795}17961797func (t *Terminal) deselectItem(item *Item) {1798 delete(t.selected, item.Index())1799 t.version++1800}18011802func (t *Terminal) deselectItemChanged(item *Item) bool {1803 if _, found := t.selected[item.Index()]; found {1804 t.deselectItem(item)1805 return true1806 }1807 return false1808}18091810func (t *Terminal) toggleItem(item *Item) bool {1811 if _, found := t.selected[item.Index()]; !found {1812 return t.selectItem(item)1813 }
543 unmodified lines
2357 togglePreview(false)2358 } else {2359 req(reqQuit)2360 }2361 case actSelect:2362 current := t.currentItem()2363 if t.multi > 0 && current != nil && t.selectItemChanged(current) {2364 req(reqList, reqInfo)2365 }2366 case actDeselect:2367 current := t.currentItem()2368 if t.multi > 0 && current != nil && t.deselectItemChanged(current) {2369 req(reqList, reqInfo)2370 }2371 case actToggle:2372 if t.multi > 0 && t.merger.Length() > 0 && toggle() {2373 req(reqList)2374 }
340 unmodified lines
modified:test/test_go.rb+21 added
1888 unmodified lines
1889 tmux.send_keys 'C-c'1890 tmux.send_keys 'C-l', 'closed'1891 tmux.until { |lines| assert_includes lines[0], 'closed' }1892 end18931894 def test_select_deselect1895 tmux.send_keys "seq 3 | #{FZF} --multi --bind up:deselect+up,down:select+down", :Enter1896 tmux.until { |lines| assert_equal 3, lines.match_count }1897 tmux.send_keys :Tab1898 tmux.until { |lines| assert_equal 1, lines.select_count }1899 tmux.send_keys :Up1900 tmux.until { |lines| assert_equal 0, lines.select_count }1901 tmux.send_keys :Down, :Down1902 tmux.until { |lines| assert_equal 2, lines.select_count }1903 tmux.send_keys :Tab1904 tmux.until { |lines| assert_equal 1, lines.select_count }1905 tmux.send_keys :Down, :Down1906 tmux.until { |lines| assert_equal 2, lines.select_count }1907 tmux.send_keys :Up1908 tmux.until { |lines| assert_equal 1, lines.select_count }1909 tmux.send_keys :Down1910 tmux.until { |lines| assert_equal 1, lines.select_count }1911 tmux.send_keys :Down1912 tmux.until { |lines| assert_equal 2, lines.select_count }1913 end1914end19151916module TestShell1917 def setup
478 unmodified lines
modified:CHANGELOG.md+6 added
1CHANGELOG2=========340.25.25------6- Added `select` and `deselect` action for unconditinoally selecting or7 deselecting a single item in `--multi` mode. Complements `toggle` action.8- Built with Go 1.169100.25.111------12- Added `close` action13 - Close preview window if open, abort fzf otherwise
1075 unmodified lines