Allow put action with an argument i.e. put(...)
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 12af069 · Browse files · 5 files·+24 added−1 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+24 added−1 removed
- tests:+9 added−0 removed
- other:+15 added−1 removed
Provenance
- Commit
4b3f0b9- Tree
c74604c- Author
Junegunn Choi <junegunn.c@gmail.com>- Committer
Junegunn Choi <junegunn.c@gmail.com>- Parent
12af069
5 files changed+24 added−1 removed
modified:man/man1/fzf.1+1 added
1006 unmodified lines1007 \fBpreview-bottom\fR1008 \fBpreview-top\fR1009 \fBprint-query\fR (print query and exit)1010 \fBput\fR (put the character to the prompt)1011+ \fBput(...)\fR (put the given string to the prompt)1012 \fBrefresh-preview\fR1013 \fBrebind(...)\fR (rebind bindings after \fBunbind\fR)1014 \fBreload(...)\fR (see below for the details)1015 \fBreplace-query\fR (replace query string with the current selection)152 unmodified linesmodified:src/options.go+3 added-1 removed
888 unmodified lines889 )890 891 func init() {892 executeRegexp = regexp.MustCompile(893- `(?si)[:+](execute(?:-multi|-silent)?|reload|preview|change-query|change-prompt|change-preview-window|change-preview|(?:re|un)bind|pos)`)893+ `(?si)[:+](execute(?:-multi|-silent)?|reload|preview|change-query|change-prompt|change-preview-window|change-preview|(?:re|un)bind|pos|put)`)894 splitRegexp = regexp.MustCompile("[,:]+")895 actionNameRegexp = regexp.MustCompile("(?i)^[a-z-]+")896 }897 306 unmodified lines1204 case "execute-silent":1205 return actExecuteSilent1206 case "execute-multi":1207 return actExecuteMulti1208+ case "put":1209+ return actPut1210 }1211 return actIgnore1212 }1213 761 unmodified linesmodified:src/terminal.go+6 added
319 unmodified lines320 actPreviewHalfPageUp321 actPreviewHalfPageDown322 actPrevHistory323 actPrevSelected324+ actPut325 actNextHistory326 actNextSelected327 actExecute328 actExecuteSilent2519 unmodified lines2848 }2849 t.vset(n)2850 req(reqList)2851 }2852+ case actPut:2853+ str := []rune(a.a)2854+ suffix := copySlice(t.input[t.cx:])2855+ t.input = append(append(t.input[:t.cx], str...), suffix...)2856+ t.cx += len(str)2857 case actUnixLineDiscard:2858 beof = len(t.input) == 02859 if t.cx > 0 {2860 t.yanked = copySlice(t.input[:t.cx])358 unmodified linesmodified:test/test_go.rb+9 added
1618 unmodified lines1619 tmux.send_keys :e1620 tmux.until { |lines| assert_includes lines[1], ' 1/1' }1621 end1622 1623+ def test_put1624+ tmux.send_keys %(seq 1000 | #{FZF} --bind 'a:put+put,b:put+put(ravo)' --preview 'echo {q}/{q}'), :Enter1625+ tmux.until { |lines| assert_equal 1000, lines.match_count }1626+ tmux.send_keys :a1627+ tmux.until { |lines| assert_includes lines[1], ' aa/aa' }1628+ tmux.send_keys :b1629+ tmux.until { |lines| assert_includes lines[1], ' aabravo/aabravo' }1630+ end1631+1632 def test_accept_non_empty1633 tmux.send_keys %(seq 1000 | #{fzf('--print-query --bind enter:accept-non-empty')}), :Enter1634 tmux.until { |lines| assert_equal 1000, lines.match_count }1635 tmux.send_keys 'foo'1318 unmodified linesmodified:CHANGELOG.md+5 added
30 unmodified lines31 # Both actions respect --layout option32 seq 10 | fzf --multi --bind ctrl-n:next-selected,ctrl-p:prev-selected --layout reverse33 ```34 - Added `change-query(...)` action35+- `put` action can optionally take an argument string36+ ```sh37+ # a will put 'alpha' on the prompt, ctrl-b will put 'bravo'38+ fzf --bind 'a:put+put(lpha),ctrl-b:put(bravo)'39+ ```40 - `double-click` will behave the same as `enter` unless otherwise specified,41 so you don't have to repeat the same action twice in `--bind` in most cases.42 ```sh43 # No need to bind 'double-click' to the same action1395 unmodified lines