mirror of
https://github.com/Llewellynvdm/fzf.git
synced 2024-06-05 00:40:50 +00:00
Add "eof" action which closes the finder only when input is empty
Close #289
This commit is contained in:
parent
b53f61fc59
commit
cc0d5539ba
|
@ -9,6 +9,8 @@ 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"`
|
||||
|
||||
### Minor improvements/fixes
|
||||
|
||||
|
|
|
@ -193,6 +193,7 @@ e.g. \fBfzf --bind=ctrl-j:accept,ctrl-k:kill-line\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
|
||||
|
|
|
@ -499,6 +499,8 @@ func parseKeymap(keymap map[int]actionType, execmap map[int]string, toggleSort b
|
|||
keymap[key] = actDeleteChar
|
||||
case "end-of-line":
|
||||
keymap[key] = actEndOfLine
|
||||
case "eof":
|
||||
keymap[key] = actEof
|
||||
case "forward-char":
|
||||
keymap[key] = actForwardChar
|
||||
case "forward-word":
|
||||
|
|
|
@ -103,6 +103,7 @@ const (
|
|||
actClearScreen
|
||||
actDeleteChar
|
||||
actEndOfLine
|
||||
actEof
|
||||
actForwardChar
|
||||
actForwardWord
|
||||
actKillLine
|
||||
|
@ -813,6 +814,10 @@ func (t *Terminal) Loop() {
|
|||
}
|
||||
case actEndOfLine:
|
||||
t.cx = len(t.input)
|
||||
case actEof:
|
||||
if len(t.input) == 0 {
|
||||
req(reqQuit)
|
||||
}
|
||||
case actForwardChar:
|
||||
if t.cx < len(t.input) {
|
||||
t.cx++
|
||||
|
|
|
@ -718,6 +718,19 @@ 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') }
|
||||
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] == '>' }
|
||||
tmux.send_keys 2
|
||||
tmux.prepare
|
||||
end
|
||||
|
||||
private
|
||||
def writelines path, lines
|
||||
File.unlink path while File.exists? path
|
||||
|
|
Loading…
Reference in New Issue
Block a user