Skip to content
Myr

Add backward-delete-char/eof action (#1891)

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

'backward-delete-char/eof' will either abort if query is empty or delete one character backwards.

authored by James Wright · committed by GitHub · parent d8cb5c1 · Browse files · 4 files+72 added−47 removed
This commit

State

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

Diff stats

4 files+72 added−47 removed

  • tests:+14 added−0 removed
  • other:+58 added−47 removed

4 files+72 added−47 removed

modified:man/man1/fzf.1+48 added-47 removed
631 unmodified lines
632633.SS AVAILABLE ACTIONS:634A key or an event can be bound to one or more of the following actions.635636 \fBACTION: DEFAULT BINDINGS (NOTES):637 \fBabort\fR \fIctrl-c ctrl-g ctrl-q esc\fR638 \fBaccept\fR \fIenter double-click\fR639 \fBaccept-non-empty\fR (same as \fBaccept\fR except that it prevents fzf from exiting without selection)640 \fBbackward-char\fR \fIctrl-b left\fR641 \fBbackward-delete-char\fR \fIctrl-h bspace\fR642 \fBbackward-kill-word\fR \fIalt-bs\fR643 \fBbackward-word\fR \fIalt-b shift-left\fR644 \fBbeginning-of-line\fR \fIctrl-a home\fR645 \fBcancel\fR (clear query string if not empty, abort fzf otherwise)646 \fBclear-screen\fR \fIctrl-l\fR647 \fBclear-selection\fR (clear multi-selection)648 \fBclear-query\fR (clear query string)649 \fBdelete-char\fR \fIdel\fR650 \fBdelete-char/eof\fR \fIctrl-d\fR651 \fBdeselect-all\fR (deselect all matches)652 \fBdown\fR \fIctrl-j ctrl-n down\fR653 \fBend-of-line\fR \fIctrl-e end\fR654 \fBexecute(...)\fR (see below for the details)655 \fBexecute-silent(...)\fR (see below for the details)656 \fRexecute-multi(...)\fR (deprecated in favor of \fB{+}\fR expression)657 \fBforward-char\fR \fIctrl-f right\fR658 \fBforward-word\fR \fIalt-f shift-right\fR636 \fBACTION: DEFAULT BINDINGS (NOTES):637 \fBabort\fR \fIctrl-c ctrl-g ctrl-q esc\fR638 \fBaccept\fR \fIenter double-click\fR639 \fBaccept-non-empty\fR (same as \fBaccept\fR except that it prevents fzf from exiting without selection)640 \fBbackward-char\fR \fIctrl-b left\fR641 \fBbackward-delete-char\fR \fIctrl-h bspace\fR642 \fBbackward-delete-char/eof\fR (same as \fBbackward-delete-char\fR except aborts fzf if query is empty)643 \fBbackward-kill-word\fR \fIalt-bs\fR644 \fBbackward-word\fR \fIalt-b shift-left\fR645 \fBbeginning-of-line\fR \fIctrl-a home\fR646 \fBcancel\fR (clear query string if not empty, abort fzf otherwise)647 \fBclear-screen\fR \fIctrl-l\fR648 \fBclear-selection\fR (clear multi-selection)649 \fBclear-query\fR (clear query string)650 \fBdelete-char\fR \fIdel\fR651 \fBdelete-char/eof\fR \fIctrl-d\fR (same as \fBdelete-char\fR except aborts fzf if query is empty)652 \fBdeselect-all\fR (deselect all matches)653 \fBdown\fR \fIctrl-j ctrl-n down\fR654 \fBend-of-line\fR \fIctrl-e end\fR655 \fBexecute(...)\fR (see below for the details)656 \fBexecute-silent(...)\fR (see below for the details)657 \fRexecute-multi(...)\fR (deprecated in favor of \fB{+}\fR expression)658 \fBforward-char\fR \fIctrl-f right\fR659 \fBforward-word\fR \fIalt-f shift-right\fR660 \fBignore\fR660 \fBjump\fR (EasyMotion-like 2-keystroke movement)661 \fBjump-accept\fR (jump and accept)661 \fBjump\fR (EasyMotion-like 2-keystroke movement)662 \fBjump-accept\fR (jump and accept)663 \fBkill-line\fR663 \fBkill-word\fR \fIalt-d\fR664 \fBnext-history\fR (\fIctrl-n\fR on \fB--history\fR)665 \fBpage-down\fR \fIpgdn\fR666 \fBpage-up\fR \fIpgup\fR664 \fBkill-word\fR \fIalt-d\fR665 \fBnext-history\fR (\fIctrl-n\fR on \fB--history\fR)666 \fBpage-down\fR \fIpgdn\fR667 \fBpage-up\fR \fIpgup\fR668 \fBhalf-page-down\fR669 \fBhalf-page-up\fR669 \fBpreview-down\fR \fIshift-down\fR670 \fBpreview-up\fR \fIshift-up\fR670 \fBpreview-down\fR \fIshift-down\fR671 \fBpreview-up\fR \fIshift-up\fR672 \fBpreview-page-down\fR673 \fBpreview-page-up\fR673 \fBprevious-history\fR (\fIctrl-p\fR on \fB--history\fR)674 \fBprint-query\fR (print query and exit)675 \fBreload(...)\fR (see below for the details)676 \fBreplace-query\fR (replace query string with the current selection)677 \fBselect-all\fR (select all matches)678 \fBtoggle\fR (\fIright-click\fR)679 \fBtoggle-all\fR (toggle all matches)680 \fBtoggle+down\fR \fIctrl-i (tab)\fR681 \fBtoggle-in\fR (\fB--layout=reverse*\fR ? \fBtoggle+up\fR : \fBtoggle+down\fR)682 \fBtoggle-out\fR (\fB--layout=reverse*\fR ? \fBtoggle+down\fR : \fBtoggle+up\fR)674 \fBprevious-history\fR (\fIctrl-p\fR on \fB--history\fR)675 \fBprint-query\fR (print query and exit)676 \fBreload(...)\fR (see below for the details)677 \fBreplace-query\fR (replace query string with the current selection)678 \fBselect-all\fR (select all matches)679 \fBtoggle\fR (\fIright-click\fR)680 \fBtoggle-all\fR (toggle all matches)681 \fBtoggle+down\fR \fIctrl-i (tab)\fR682 \fBtoggle-in\fR (\fB--layout=reverse*\fR ? \fBtoggle+up\fR : \fBtoggle+down\fR)683 \fBtoggle-out\fR (\fB--layout=reverse*\fR ? \fBtoggle+down\fR : \fBtoggle+up\fR)684 \fBtoggle-preview\fR685 \fBtoggle-preview-wrap\fR686 \fBtoggle-sort\fR686 \fBtoggle+up\fR \fIbtab (shift-tab)\fR687 \fBtop\fR (move to the top result)688 \fBunix-line-discard\fR \fIctrl-u\fR689 \fBunix-word-rubout\fR \fIctrl-w\fR690 \fBup\fR \fIctrl-k ctrl-p up\fR691 \fByank\fR \fIctrl-y\fR687 \fBtoggle+up\fR \fIbtab (shift-tab)\fR688 \fBtop\fR (move to the top result)689 \fBunix-line-discard\fR \fIctrl-u\fR690 \fBunix-word-rubout\fR \fIctrl-w\fR691 \fBup\fR \fIctrl-k ctrl-p up\fR692 \fByank\fR \fIctrl-y\fR693694.SS ACTION COMPOSITION695696Multiple actions can be chained using \fB+\fR separator.
83 unmodified lines
modified:src/options.go+2 added
738 unmodified lines
739 case "backward-char":740 appendAction(actBackwardChar)741 case "backward-delete-char":742 appendAction(actBackwardDeleteChar)743 case "backward-delete-char/eof":744 appendAction(actBackwardDeleteCharEOF)745 case "backward-word":746 appendAction(actBackwardWord)747 case "clear-screen":748 appendAction(actClearScreen)
698 unmodified lines
modified:src/terminal.go+8 added
185 unmodified lines
186 actAccept187 actAcceptNonEmpty188 actBackwardChar189 actBackwardDeleteChar190 actBackwardDeleteCharEOF191 actBackwardWord192 actCancel193 actClearScreen194 actClearQuery
1651 unmodified lines
1846 t.yanked = t.input1847 t.input = []rune{}1848 t.cx = 01849 }1850 case actBackwardDeleteCharEOF:1851 if len(t.input) == 0 {1852 req(reqQuit)1853 } else if t.cx > 0 {1854 t.input = append(t.input[:t.cx-1], t.input[t.cx:]...)1855 t.cx--1856 }1857 case actForwardChar:1858 if t.cx < len(t.input) {1859 t.cx++1860 }
349 unmodified lines
modified:test/test_go.rb+14 added
1708 unmodified lines
1709 tmux.send_keys :Space1710 tmux.until { |lines| lines.match_count.zero? }1711 tmux.until { |lines| !lines[-2].include?('(1)') }1712 end17131714 def test_backward_delete_char_eof1715 tmux.send_keys "seq 1000 | #{fzf "--bind 'bs:backward-delete-char/eof'"}", :Enter1716 tmux.until { |lines| lines[-2] == ' 1000/1000' }1717 tmux.send_keys '11'1718 tmux.until { |lines| lines[-1] == '> 11' }1719 tmux.send_keys :BSpace1720 tmux.until { |lines| lines[-1] == '> 1' }1721 tmux.send_keys :BSpace1722 tmux.until { |lines| lines[-1] == '>' }1723 tmux.send_keys :BSpace1724 tmux.prepare1725 end17261727end17281729module TestShell1730 def setup
370 unmodified lines