Add `close` action

Close #2331
pull/2340/head
Junegunn Choi 3 years ago
parent d110372f99
commit f55c990e86
No known key found for this signature in database
GPG Key ID: 254BC280FEF9C627

@ -1,6 +1,11 @@
CHANGELOG CHANGELOG
========= =========
0.25.1
------
- Added `close` action
- Close preview window if open, abort fzf otherwise
0.25.0 0.25.0
------ ------
- Text attributes set in `--color` are not reset when fzf sees another - Text attributes set in `--color` are not reset when fzf sees another

@ -21,7 +21,7 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE. THE SOFTWARE.
.. ..
.TH fzf-tmux 1 "Jan 2021" "fzf 0.25.0" "fzf-tmux - open fzf in tmux split pane" .TH fzf-tmux 1 "Feb 2021" "fzf 0.25.1" "fzf-tmux - open fzf in tmux split pane"
.SH NAME .SH NAME
fzf-tmux - open fzf in tmux split pane fzf-tmux - open fzf in tmux split pane

@ -21,7 +21,7 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE. THE SOFTWARE.
.. ..
.TH fzf 1 "Jan 2021" "fzf 0.25.0" "fzf - a command-line fuzzy finder" .TH fzf 1 "Feb 2021" "fzf 0.25.1" "fzf - a command-line fuzzy finder"
.SH NAME .SH NAME
fzf - a command-line fuzzy finder fzf - a command-line fuzzy finder
@ -780,6 +780,7 @@ A key or an event can be bound to one or more of the following actions.
\fBchange-prompt(...)\fR (change prompt to the given string) \fBchange-prompt(...)\fR (change prompt to the given string)
\fBclear-screen\fR \fIctrl-l\fR \fBclear-screen\fR \fIctrl-l\fR
\fBclear-selection\fR (clear multi-selection) \fBclear-selection\fR (clear multi-selection)
\fBclose\fR (close preview window if open, abort fzf otherwise)
\fBclear-query\fR (clear query string) \fBclear-query\fR (clear query string)
\fBdelete-char\fR \fIdel\fR \fBdelete-char\fR \fIdel\fR
\fBdelete-char/eof\fR \fIctrl-d\fR (same as \fBdelete-char\fR except aborts fzf if query is empty) \fBdelete-char/eof\fR \fIctrl-d\fR (same as \fBdelete-char\fR except aborts fzf if query is empty)

@ -883,6 +883,8 @@ func parseKeymap(keymap map[tui.Event][]action, str string) {
appendAction(actSelectAll) appendAction(actSelectAll)
case "deselect-all": case "deselect-all":
appendAction(actDeselectAll) appendAction(actDeselectAll)
case "close":
appendAction(actClose)
case "toggle": case "toggle":
appendAction(actToggle) appendAction(actToggle)
case "down": case "down":

@ -221,6 +221,7 @@ const (
actClearScreen actClearScreen
actClearQuery actClearQuery
actClearSelection actClearSelection
actClose
actDeleteChar actDeleteChar
actDeleteCharEOF actDeleteCharEOF
actEndOfLine actEndOfLine
@ -2334,6 +2335,12 @@ func (t *Terminal) Loop() {
} }
req(reqList, reqInfo) req(reqList, reqInfo)
} }
case actClose:
if t.isPreviewEnabled() {
togglePreview(false)
} else {
req(reqQuit)
}
case actToggle: case actToggle:
if t.multi > 0 && t.merger.Length() > 0 && toggle() { if t.multi > 0 && t.merger.Length() > 0 && toggle() {
req(reqList) req(reqList)

@ -1877,6 +1877,19 @@ class TestGoFZF < TestBase
tmux.send_keys 'C-w' tmux.send_keys 'C-w'
end end
end end
def test_close
tmux.send_keys "seq 100 | #{FZF} --preview 'echo foo' --bind ctrl-c:close", :Enter
tmux.until { |lines| assert_equal 100, lines.match_count }
tmux.until { |lines| assert_includes lines[1], 'foo' }
tmux.send_keys 'C-c'
tmux.until { |lines| refute_includes lines[1], 'foo' }
tmux.send_keys '10'
tmux.until { |lines| assert_equal 2, lines.match_count }
tmux.send_keys 'C-c'
tmux.send_keys 'C-l', 'closed'
tmux.until { |lines| assert_includes lines[0], 'closed' }
end
end end
module TestShell module TestShell

Loading…
Cancel
Save