Skip to content

Commit

Permalink
Fix problem if the prefix is shorter than the input.
Browse files Browse the repository at this point in the history
This happens if the user types 'ab'<TAB> while there exists files like 'abc' and 'aBC'. In that case, the prefix shrinks to 'a'.
  • Loading branch information
jochenwierum committed Feb 20, 2024
1 parent 30f2aad commit 9d8cc16
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions fzf-tab.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -142,7 +143,7 @@
compstate[insert]=
if (( $#_ftb_query > 0 )); then
compstate[insert]='2'
[[ $RBUFFER == ' '* ]] || compstate[insert]+=' '
[[ $RBUFFER == ' '* ]] && compstate[insert]+=' '
fi
return 0
else
Expand Down

0 comments on commit 9d8cc16

Please sign in to comment.