mirror of
https://github.com/junegunn/fzf.git
synced 2025-08-01 12:42:01 -07:00
Add "eof" action which closes the finder only when input is empty
Close #289
This commit is contained in:
@@ -9,6 +9,8 @@ CHANGELOG
|
|||||||
- Added options for sticky header
|
- Added options for sticky header
|
||||||
- `--header-file`
|
- `--header-file`
|
||||||
- `--header-lines`
|
- `--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
|
### Minor improvements/fixes
|
||||||
|
|
||||||
|
@@ -193,6 +193,7 @@ e.g. \fBfzf --bind=ctrl-j:accept,ctrl-k:kill-line\fR
|
|||||||
\fBdeselect-all\fR
|
\fBdeselect-all\fR
|
||||||
\fBdown\fR \fIctrl-j ctrl-n down\fR
|
\fBdown\fR \fIctrl-j ctrl-n down\fR
|
||||||
\fBend-of-line\fR \fIctrl-e end\fR
|
\fBend-of-line\fR \fIctrl-e end\fR
|
||||||
|
\fBeof\fR
|
||||||
\fBexecute(...)\fR (see below for the details)
|
\fBexecute(...)\fR (see below for the details)
|
||||||
\fBforward-char\fR \fIctrl-f right\fR
|
\fBforward-char\fR \fIctrl-f right\fR
|
||||||
\fBforward-word\fR \fIalt-f shift-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
|
keymap[key] = actDeleteChar
|
||||||
case "end-of-line":
|
case "end-of-line":
|
||||||
keymap[key] = actEndOfLine
|
keymap[key] = actEndOfLine
|
||||||
|
case "eof":
|
||||||
|
keymap[key] = actEof
|
||||||
case "forward-char":
|
case "forward-char":
|
||||||
keymap[key] = actForwardChar
|
keymap[key] = actForwardChar
|
||||||
case "forward-word":
|
case "forward-word":
|
||||||
|
@@ -103,6 +103,7 @@ const (
|
|||||||
actClearScreen
|
actClearScreen
|
||||||
actDeleteChar
|
actDeleteChar
|
||||||
actEndOfLine
|
actEndOfLine
|
||||||
|
actEof
|
||||||
actForwardChar
|
actForwardChar
|
||||||
actForwardWord
|
actForwardWord
|
||||||
actKillLine
|
actKillLine
|
||||||
@@ -813,6 +814,10 @@ func (t *Terminal) Loop() {
|
|||||||
}
|
}
|
||||||
case actEndOfLine:
|
case actEndOfLine:
|
||||||
t.cx = len(t.input)
|
t.cx = len(t.input)
|
||||||
|
case actEof:
|
||||||
|
if len(t.input) == 0 {
|
||||||
|
req(reqQuit)
|
||||||
|
}
|
||||||
case actForwardChar:
|
case actForwardChar:
|
||||||
if t.cx < len(t.input) {
|
if t.cx < len(t.input) {
|
||||||
t.cx++
|
t.cx++
|
||||||
|
@@ -718,6 +718,19 @@ class TestGoFZF < TestBase
|
|||||||
end
|
end
|
||||||
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
|
private
|
||||||
def writelines path, lines
|
def writelines path, lines
|
||||||
File.unlink path while File.exists? path
|
File.unlink path while File.exists? path
|
||||||
|
Reference in New Issue
Block a user