From f6e9b73d00c54128b51f9b614f1761a9f3a0e4d8 Mon Sep 17 00:00:00 2001 From: NICHOLAS85 <15698885+NICHOLAS85@users.noreply.github.com> Date: Mon, 2 Nov 2020 02:01:08 -0500 Subject: [PATCH 1/4] feat: add support of accept-line --- fzf-tab.zsh | 8 +++++++- lib/-ftb-fzf | 2 +- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/fzf-tab.zsh b/fzf-tab.zsh index 175fc67..28fc4ac 100644 --- a/fzf-tab.zsh +++ b/fzf-tab.zsh @@ -116,6 +116,7 @@ -ftb-generate-header # sets `_ftb_headers` -ftb-zstyle -s continuous-trigger continuous_trigger || continuous_trigger=/ -ftb-zstyle -s print-query print_query || print_query=alt-enter + -ftb-zstyle -s accept-line accept_line || accept_line=enter # NOTE: Using pipe here causes an error "failed to read /dev/tty" # when _ftb_complist is long @@ -145,6 +146,10 @@ if [[ $choices[1] && $choices[1] == $continuous_trigger ]]; then typeset -gi _ftb_continue=1 fi + + if [[ $choices[1] && $choices[1] == $accept_line ]]; then + typeset -gi _ftb_accept=1 + fi choices[1]=() for choice in "$choices[@]"; do @@ -170,6 +175,7 @@ fzf-tab-complete() { local -i _ftb_continue=1 while (( _ftb_continue )); do _ftb_continue=0 + _ftb_accept=0 local IN_FZF_TAB=1 { zle .fzf-tab-orig-$_ftb_orig_widget @@ -181,7 +187,7 @@ fzf-tab-complete() { zle .reset-prompt zle -R else - zle redisplay + (( _ftb_accept )) && zle accept-line || zle redisplay fi done } diff --git a/lib/-ftb-fzf b/lib/-ftb-fzf index 5f2df8a..5d86db0 100644 --- a/lib/-ftb-fzf +++ b/lib/-ftb-fzf @@ -49,7 +49,7 @@ choices="$($fzf_command \ --color=hl:$(( header_lines == 0 ? 188 : 255 )) \ --cycle \ --delimiter='\x00' \ - --expect=$continuous_trigger,$print_query \ + --expect=$continuous_trigger,$print_query,$accept_line \ --header-lines=$header_lines \ --height=${FZF_TMUX_HEIGHT:=$(( lines > LINES / 3 * 2 ? LINES / 3 * 2 : lines ))} \ --layout=reverse \ From cde54175b6a8ac0c69f46f850598fcbf2ef89ea3 Mon Sep 17 00:00:00 2001 From: NICHOLAS85 <15698885+NICHOLAS85@users.noreply.github.com> Date: Mon, 2 Nov 2020 03:47:57 -0500 Subject: [PATCH 2/4] Make accept-line a local variable --- fzf-tab.zsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fzf-tab.zsh b/fzf-tab.zsh index 28fc4ac..e37a7cb 100644 --- a/fzf-tab.zsh +++ b/fzf-tab.zsh @@ -95,7 +95,7 @@ -ftb-complete() { local -a _ftb_compcap local -Ua _ftb_groups - local choice choices _ftb_curcontext continuous_trigger print_query bs=$'\2' nul=$'\0' + local choice choices _ftb_curcontext continuous_trigger print_query accept_line bs=$'\2' nul=$'\0' # must run with user options; don't move `emulate -L zsh` above this line (( $+builtins[fzf-tab-compcap-generate] )) && fzf-tab-compcap-generate -i From b92b3359beb1137ed54d52d339d74be48cc6261d Mon Sep 17 00:00:00 2001 From: NICHOLAS85 <15698885+NICHOLAS85@users.noreply.github.com> Date: Mon, 2 Nov 2020 14:52:34 -0500 Subject: [PATCH 3/4] Make _ftb_accept a local variable --- fzf-tab.zsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fzf-tab.zsh b/fzf-tab.zsh index e37a7cb..9e6d567 100644 --- a/fzf-tab.zsh +++ b/fzf-tab.zsh @@ -175,7 +175,7 @@ fzf-tab-complete() { local -i _ftb_continue=1 while (( _ftb_continue )); do _ftb_continue=0 - _ftb_accept=0 + local _ftb_accept=0 local IN_FZF_TAB=1 { zle .fzf-tab-orig-$_ftb_orig_widget From 4b78e1b4f0e505d0302f0f0ef548cafe641773d5 Mon Sep 17 00:00:00 2001 From: NICHOLAS85 <15698885+NICHOLAS85@users.noreply.github.com> Date: Mon, 2 Nov 2020 15:04:16 -0500 Subject: [PATCH 4/4] Do not assign a keybind to accept-line by default --- fzf-tab.zsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fzf-tab.zsh b/fzf-tab.zsh index 9e6d567..1696406 100644 --- a/fzf-tab.zsh +++ b/fzf-tab.zsh @@ -116,7 +116,7 @@ -ftb-generate-header # sets `_ftb_headers` -ftb-zstyle -s continuous-trigger continuous_trigger || continuous_trigger=/ -ftb-zstyle -s print-query print_query || print_query=alt-enter - -ftb-zstyle -s accept-line accept_line || accept_line=enter + -ftb-zstyle -s accept-line accept_line # NOTE: Using pipe here causes an error "failed to read /dev/tty" # when _ftb_complist is long