Add clear-query and clear-selection
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Close #1787 Related #1364
authored by Junegunn Choi · committed by Junegunn Choi · parent 86e3994 · Browse files · 5 files·+45 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
5 files+45 added−4 removed
- tests:+23 added−0 removed
- other:+22 added−4 removed
Provenance
- Commit
af1a5f1- Tree
2960301- Author
Junegunn Choi <junegunn.c@gmail.com>- Committer
Junegunn Choi <junegunn.c@gmail.com>- Parent
86e3994
5 files changed+45 added−4 removed
modified:man/man1/fzf.1+6 added-4 removed
630 unmodified lines631 \fBbackward-delete-char\fR \fIctrl-h bspace\fR632 \fBbackward-kill-word\fR \fIalt-bs\fR633 \fBbackward-word\fR \fIalt-b shift-left\fR634 \fBbeginning-of-line\fR \fIctrl-a home\fR635- \fBcancel\fR (clears query string if not empty, aborts fzf otherwise)635+ \fBcancel\fR (clear query string if not empty, abort fzf otherwise)636 \fBclear-screen\fR \fIctrl-l\fR637+ \fBclear-selection\fR (clear multi-selection)638+ \fBclear-query\fR (clear query string)639 \fBdelete-char\fR \fIdel\fR640 \fBdelete-char/eof\fR \fIctrl-d\fR639- \fBdeselect-all\fR641+ \fBdeselect-all\fR (deselect all matches)642 \fBdown\fR \fIctrl-j ctrl-n down\fR643 \fBend-of-line\fR \fIctrl-e end\fR644 \fBexecute(...)\fR (see below for the details)645 \fBexecute-silent(...)\fR (see below for the details)17 unmodified lines663 \fBprevious-history\fR (\fIctrl-p\fR on \fB--history\fR)664 \fBprint-query\fR (print query and exit)665 \fBreload(...)\fR (see below for the details)666 \fBreplace-query\fR (replace query string with the current selection)665- \fBselect-all\fR667+ \fBselect-all\fR (select all matches)668 \fBtoggle\fR (\fIright-click\fR)667- \fBtoggle-all\fR669+ \fBtoggle-all\fR (toggle all matches)670 \fBtoggle+down\fR \fIctrl-i (tab)\fR671 \fBtoggle-in\fR (\fB--layout=reverse*\fR ? \fBtoggle+up\fR : \fBtoggle+down\fR)672 \fBtoggle-out\fR (\fB--layout=reverse*\fR ? \fBtoggle+down\fR : \fBtoggle+up\fR)673 \fBtoggle-preview\fR95 unmodified linesmodified:src/options.go+4 added
736 unmodified lines737 case "end-of-line":738 appendAction(actEndOfLine)739 case "cancel":740 appendAction(actCancel)741+ case "clear-query":742+ appendAction(actClearQuery)743+ case "clear-selection":744+ appendAction(actClearSelection)745 case "forward-char":746 appendAction(actForwardChar)747 case "forward-word":748 appendAction(actForwardWord)638 unmodified linesmodified:src/terminal.go+11 added
183 unmodified lines184 actBackwardDeleteChar185 actBackwardWord186 actCancel187 actClearScreen188+ actClearQuery189+ actClearSelection190 actDeleteChar191 actDeleteCharEOF192 actEndOfLine193 actForwardChar1712 unmodified lines1906 req(reqClose)1907 }1908 case actClearScreen:1909 req(reqRedraw)1910+ case actClearQuery:1911+ t.input = []rune{}1912+ t.cx = 01913+ case actClearSelection:1914+ if t.multi > 0 {1915+ t.selected = make(map[int32]selectedItem)1916+ t.version++1917+ req(reqList, reqInfo)1918+ }1919 case actTop:1920 t.vset(0)1921 req(reqList)1922 case actUnixLineDiscard:257 unmodified linesmodified:test/test_go.rb+23 added
1652 unmodified lines1653 tmux.until { |lines| lines.any? { |line| line.include?('9') } }1654 tmux.send_keys :Space1655 tmux.until { |lines| lines.none? { |line| line.include?('9') } }1656 end1657+1658+ def test_clear_query1659+ tmux.send_keys %(: | #{FZF} --query foo --bind space:clear-query), :Enter1660+ tmux.until { |lines| lines.item_count.zero? }1661+ tmux.until { |lines| lines.last.include?('> foo') }1662+ tmux.send_keys 'C-a', 'bar'1663+ tmux.until { |lines| lines.last.include?('> barfoo') }1664+ tmux.send_keys :Space1665+ tmux.until { |lines| lines.last == '>' }1666+ end1667+1668+ def test_clear_selection1669+ tmux.send_keys %(seq 100 | #{FZF} --multi --bind space:clear-selection), :Enter1670+ tmux.until { |lines| lines.match_count == 100 }1671+ tmux.send_keys :Tab1672+ tmux.until { |lines| lines[-2].include?('(1)') }1673+ tmux.send_keys 'foo'1674+ tmux.until { |lines| lines.match_count.zero? }1675+ tmux.until { |lines| lines[-2].include?('(1)') }1676+ tmux.send_keys :Space1677+ tmux.until { |lines| lines.match_count.zero? }1678+ tmux.until { |lines| !lines[-2].include?('(1)') }1679+ end1680 end1681 1682 module TestShell1683 def setup370 unmodified linesmodified:CHANGELOG.md+1 added
5 unmodified lines6 - Removed the immediate flicking of the screen on `reload` action.7 ```sh8 : | fzf --bind 'change:reload:seq {q}' --phony9 ```10+- Added `clear-query` and `clear-selection` actions for `--bind`11 - It is now possible to split a composite bind action over multiple `--bind`12 expressions by prefixing the later ones with `+`.13 ```sh14 fzf --bind 'ctrl-a:up+up'782 unmodified lines