From 9d8cc1684f37f0bdc6de5f93298f759b9ac0e00e Mon Sep 17 00:00:00 2001 From: Jochen Wierum Date: Mon, 31 Jul 2023 15:35:12 +0200 Subject: [PATCH] Fix problem if the prefix is shorter than the input. This happens if the user types 'ab' while there exists files like 'abc' and 'aBC'. In that case, the prefix shrinks to 'a'. --- fzf-tab.zsh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/fzf-tab.zsh b/fzf-tab.zsh index e164624..4c86776 100644 --- a/fzf-tab.zsh +++ b/fzf-tab.zsh @@ -131,7 +131,8 @@ -ftb-generate-query # sets `_ftb_query` and `_ftb_query_prefix` - if [[ "$complete_common_prefix" == true && $_ftb_query_prefix == 1 && "${PREFIX##*/}" != "$_ftb_query" ]]; then + local curr_prefix="${PREFIX##*/}" + if [[ "$complete_common_prefix" == true && $_ftb_query_prefix == 1 && "$curr_prefix" != "$_ftb_query"* ]]; then local -A v=("${(@0)${_ftb_compcap[1]}}") local -a args=("${(@ps:\1:)v[args]}") [[ -z $args[1] ]] && args=() # don't pass an empty string @@ -142,7 +143,7 @@ compstate[insert]= if (( $#_ftb_query > 0 )); then compstate[insert]='2' - [[ $RBUFFER == ' '* ]] || compstate[insert]+=' ' + [[ $RBUFFER == ' '* ]] && compstate[insert]+=' ' fi return 0 else