Add backward-eof event for --bind
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 06d63a8 · Browse files · 5 files·+40 added−5 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+40 added−5 removed
- tests:+11 added−0 removed
- other:+29 added−5 removed
Provenance
- Commit
a7aa08c- Tree
c2b8260- Author
Junegunn Choi <junegunn.c@gmail.com>- Committer
Junegunn Choi <junegunn.c@gmail.com>- Parent
06d63a8
5 files changed+40 added−5 removed
modified:man/man1/fzf.1+16 added-5 removed
633 unmodified lines634 .br635 or any single character636 637 .SS AVAILABLE EVENTS:638-\fIchange\fR (triggered whenever the query string is changed)639-.br638+\fIchange\fR639+.RS640+Triggered whenever the query string is changed641 641- e.g.642- \fB# Moves cursor to the top (or bottom depending on --layout) whenever the query is changed643- fzf --bind change:top\fR642+e.g.643+ \fB# Moves cursor to the top (or bottom depending on --layout) whenever the query is changed644+ fzf --bind change:top\fR645+.RE646 647+\fIbackward-eof\fR648+.RS649+Triggered when the query string is already empty and you try to delete it650+backward.651+652+e.g.653+ \fBfzf --bind backward-eof:abort\fR654+.RE655+656 .SS AVAILABLE ACTIONS:657 A key or an event can be bound to one or more of the following actions.658 659 \fBACTION: DEFAULT BINDINGS (NOTES):143 unmodified linesmodified:src/tui/tui.go+1 added
85 unmodified lines86 F1187 F1288 89 Change90+ BackwardEOF91 92 AltSpace93 AltSlash94 AltBS429 unmodified linesmodified:src/options.go+2 added
462 unmodified lines463 case "ctrl-]":464 chord = tui.CtrlRightBracket465 case "change":466 chord = tui.Change467+ case "backward-eof":468+ chord = tui.BackwardEOF469 case "alt-enter", "alt-return":470 chord = tui.CtrlAltM471 case "alt-space":472 chord = tui.AltSpace1003 unmodified linesmodified:src/terminal.go+10 added
1736 unmodified lines1737 looping := true1738 for looping {1739 var newCommand *string1740 changed := false1741+ beof := false1742 queryChanged := false1743 1744 event := t.tui.GetChar()1745 135 unmodified lines1881 if t.cx < len(t.input) {1882 t.cx++1883 }1884 case actBackwardDeleteChar:1885+ beof = len(t.input) == 01886 if t.cx > 0 {1887 t.input = append(t.input[:t.cx-1], t.input[t.cx:]...)1888 t.cx--1889 }84 unmodified lines1974 case actTop:1975 t.vset(0)1976 req(reqList)1977 case actUnixLineDiscard:1978+ beof = len(t.input) == 01979 if t.cx > 0 {1980 t.yanked = copySlice(t.input[:t.cx])1981 t.input = t.input[t.cx:]1982 t.cx = 01983 }1984 case actUnixWordRubout:1985+ beof = len(t.input) == 01986 if t.cx > 0 {1987 t.rubout("\\s\\S")1988 }1989 case actBackwardKillWord:1990+ beof = len(t.input) == 01991 if t.cx > 0 {1992 t.rubout(t.wordRubout)1993 }1994 case actYank:154 unmodified lines2149 if !doActions(onChanges, tui.Change) {2150 continue2151 }2152 }2153+ if onEOFs, prs := t.keymap[tui.BackwardEOF]; beof && prs {2154+ if !doActions(onEOFs, tui.BackwardEOF) {2155+ continue2156+ }2157+ }2158 } else {2159 if mapkey == tui.Rune {2160 if idx := strings.IndexRune(t.jumpLabels, event.Char); idx >= 0 && idx < t.maxItems() && idx < t.merger.Length() {2161 t.cy = idx + t.offset80 unmodified linesmodified:test/test_go.rb+11 added
1744 unmodified lines1745 def test_keep_right1746 tmux.send_keys "seq 10000 | #{FZF} --read0 --keep-right", :Enter1747 tmux.until { |lines| assert lines.any_include?('9999 10000') }1748 end1749+1750+ def test_backward_eof1751+ tmux.send_keys "echo foo | #{FZF} --bind 'backward-eof:reload(seq 100)'", :Enter1752+ tmux.until { |lines| lines.item_count == 1 && lines.match_count == 1 }1753+ tmux.send_keys 'x'1754+ tmux.until { |lines| lines.item_count == 1 && lines.match_count == 0 }1755+ tmux.send_keys :BSpace1756+ tmux.until { |lines| lines.item_count == 1 && lines.match_count == 1 }1757+ tmux.send_keys :BSpace1758+ tmux.until { |lines| lines.item_count == 100 && lines.match_count == 100 }1759+ end1760 end1761 1762 module TestShell1763 def setup475 unmodified lines