diff --git a/CHANGELOG.md b/CHANGELOG.md index 3c6ab2c..3f41170 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,8 +9,9 @@ CHANGELOG - Added options for sticky header - `--header-file` - `--header-lines` -- Added `eof` action which closes the finder only when the input is empty - - e.g. `export FZF_DEFAULT_OPTS="--bind esc:eof"` +- Added `cancel` action which clears the input or closes the finder when the + input is already empty + - e.g. `export FZF_DEFAULT_OPTS="--bind esc:cancel"` - Added `delete-char/eof` action to differentiate `CTRL-D` and `DEL` ### Minor improvements/fixes diff --git a/man/man1/fzf.1 b/man/man1/fzf.1 index 17aac59..0c6b375 100644 --- a/man/man1/fzf.1 +++ b/man/man1/fzf.1 @@ -188,13 +188,13 @@ e.g. \fBfzf --bind=ctrl-j:accept,ctrl-k:kill-line\fR \fBbackward-kill-word\fR \fIalt-bs\fR \fBbackward-word\fR \fIalt-b shift-left\fR \fBbeginning-of-line\fR \fIctrl-a home\fR + \fBcancel\fR \fBclear-screen\fR \fIctrl-l\fR \fBdelete-char\fR \fIdel\fR \fBdelete-char/eof\fR \fIctrl-d\fR \fBdeselect-all\fR \fBdown\fR \fIctrl-j ctrl-n down\fR \fBend-of-line\fR \fIctrl-e end\fR - \fBeof\fR \fBexecute(...)\fR (see below for the details) \fBforward-char\fR \fIctrl-f right\fR \fBforward-word\fR \fIalt-f shift-right\fR diff --git a/src/options.go b/src/options.go index bb6da9e..5ab511d 100644 --- a/src/options.go +++ b/src/options.go @@ -501,8 +501,8 @@ func parseKeymap(keymap map[int]actionType, execmap map[int]string, toggleSort b keymap[key] = actDeleteCharEof case "end-of-line": keymap[key] = actEndOfLine - case "eof": - keymap[key] = actEof + case "cancel": + keymap[key] = actCancel case "forward-char": keymap[key] = actForwardChar case "forward-word": diff --git a/src/terminal.go b/src/terminal.go index cbc19ba..18b37d5 100644 --- a/src/terminal.go +++ b/src/terminal.go @@ -100,11 +100,11 @@ const ( actBackwardChar actBackwardDeleteChar actBackwardWord + actCancel actClearScreen actDeleteChar actDeleteCharEof actEndOfLine - actEof actForwardChar actForwardWord actKillLine @@ -817,9 +817,13 @@ func (t *Terminal) Loop() { } case actEndOfLine: t.cx = len(t.input) - case actEof: + case actCancel: if len(t.input) == 0 { req(reqQuit) + } else { + t.yanked = t.input + t.input = []rune{} + t.cx = 0 } case actForwardChar: if t.cx < len(t.input) { diff --git a/test/test_go.rb b/test/test_go.rb index 4f247ed..ad2150e 100644 --- a/test/test_go.rb +++ b/test/test_go.rb @@ -718,14 +718,14 @@ class TestGoFZF < TestBase end end - def test_eof - tmux.send_keys "seq 100 | #{fzf "--bind 2:eof"}", :Enter - tmux.until { |lines| lines[-2].include?('100/100') } + def test_canel + tmux.send_keys "seq 10 | #{fzf "--bind 2:cancel"}", :Enter + tmux.until { |lines| lines[-2].include?('10/10') } tmux.send_keys '123' - tmux.until do |lines| - lines[-1] == '> 13' && lines[-2].include?('1/100') - end - tmux.send_keys :BSpace, :BSpace + tmux.until { |lines| lines[-1] == '> 3' && lines[-2].include?('1/10') } + tmux.send_keys 'C-y', 'C-y' + tmux.until { |lines| lines[-1] == '> 311' } + tmux.send_keys 2 tmux.until { |lines| lines[-1] == '>' } tmux.send_keys 2 tmux.prepare