Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix issue where error is shown in fzf v0.56.1 or later #251

Merged
merged 3 commits into from
Nov 21, 2024

Conversation

hexium310
Copy link
Collaborator

After fzf v0.56.1, in all situations, shown completions are paths, and the following error is displayed.

__fzf_extract_command:3: compstate: assignment to invalid subscript range

_fzf_extract_command has been rewritten and is no longer directly called, which is the cause of this issue. This PR replaces it with the global $cmd_word according to the change of fzf.

ref: junegunn/fzf@57c08d9

local arguments=("${(Q)${(z)@}[@]}")
local cmd=$(__fzf_extract_command "$@")

if [[ "$(which __fzf_extract_command)" == *compstate* ]]; then
Copy link
Collaborator Author

@hexium310 hexium310 Nov 18, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not the result of fzf --version but $(which __fzf_extract_command) is used because there may be who are fetching only completion.zsh` such as me. https://github.com/hexium310/dotfiles/blob/6b61cdf90e49bb08824dcd779370436189cf010e/config/zsh/.zshrc#L23

@hexium310 hexium310 marked this pull request as ready for review November 18, 2024 20:24
@hexium310 hexium310 requested a review from chitoku-k November 18, 2024 20:24
@hexium310 hexium310 added the bug Something isn't working label Nov 18, 2024
@chitoku-k
Copy link
Owner

Thanks for your effort on your investigation and modification so as to keep up with the latest version of fzf. How about checking the existence of the cmd_word variable rather than the body of the completion function? This should make much more sense as it finally adopts the value of the variable anyway when it found one.

@chitoku-k
Copy link
Owner

Can we use parameter expansion there for simplicity?

@chitoku-k
Copy link
Owner

As I briefly tested this PR, I don’t think this is enough to support the commit you mentioned (junegunn/fzf@57c08d9).

Let’s think of this example:

$ git checkout master; git fetch **<TAB>

@hexium310
Copy link
Collaborator Author

hexium310 commented Nov 21, 2024

The completion of the second and subsequent executions may not be supported on the master branch either.

git checkout master
# v0.56.0 doesn't have the change of __fzf_extract_command
source <(curl -L https://github.com/junegunn/fzf/raw/refs/tags/v0.56.0/shell/completion.zsh) fzf-zsh-completions.plugin.zsh

Copy link
Owner

@chitoku-k chitoku-k left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, let’s merge this now and add support for the new completion available since fzf v0.56.1 later on.

@chitoku-k chitoku-k changed the title Fix issue where wrong completions and error are shown in fzf v0.56.1 or later Fix issue where error is shown in fzf v0.56.1 or later Nov 21, 2024
@chitoku-k chitoku-k merged commit bae6af7 into master Nov 21, 2024
10 checks passed
@chitoku-k chitoku-k deleted the fix/extract-command branch November 21, 2024 08:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants