Skip to content
Myr

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

5 files+40 added−5 removed

modified:man/man1/fzf.1+16 added-5 removed
633 unmodified lines
634.br635or any single character636637.SS AVAILABLE EVENTS:638\fIchange\fR (triggered whenever the query string is changed)639.br638\fIchange\fR639.RS640Triggered whenever the query string is changed641641 e.g.642 \fB# Moves cursor to the top (or bottom depending on --layout) whenever the query is changed643 fzf --bind change:top\fR642e.g.643 \fB# Moves cursor to the top (or bottom depending on --layout) whenever the query is changed644 fzf --bind change:top\fR645.RE646647\fIbackward-eof\fR648.RS649Triggered when the query string is already empty and you try to delete it650backward.651652e.g.653 \fBfzf --bind backward-eof:abort\fR654.RE655656.SS AVAILABLE ACTIONS:657A key or an event can be bound to one or more of the following actions.658659 \fBACTION: DEFAULT BINDINGS (NOTES):
143 unmodified lines
modified:src/tui/tui.go+1 added
85 unmodified lines
86 F1187 F128889 Change90 BackwardEOF9192 AltSpace93 AltSlash94 AltBS
429 unmodified lines
modified:src/options.go+2 added
462 unmodified lines
463 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.AltSpace
1003 unmodified lines
modified:src/terminal.go+10 added
1736 unmodified lines
1737 looping := true1738 for looping {1739 var newCommand *string1740 changed := false1741 beof := false1742 queryChanged := false17431744 event := t.tui.GetChar()1745
135 unmodified lines
1881 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 lines
1974 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 lines
2149 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.offset
80 unmodified lines
modified:test/test_go.rb+11 added
1744 unmodified lines
1745 def test_keep_right1746 tmux.send_keys "seq 10000 | #{FZF} --read0 --keep-right", :Enter1747 tmux.until { |lines| assert lines.any_include?('9999 10000') }1748 end17491750 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 end1760end17611762module TestShell1763 def setup
475 unmodified lines