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

0.56.1/2 breaks my FZF_COMPLETION_TRIGGER #4088

Closed
5 of 10 tasks
jefferickson opened this issue Nov 11, 2024 · 4 comments · Fixed by #4090
Closed
5 of 10 tasks

0.56.1/2 breaks my FZF_COMPLETION_TRIGGER #4088

jefferickson opened this issue Nov 11, 2024 · 4 comments · Fixed by #4090

Comments

@jefferickson
Copy link

jefferickson commented Nov 11, 2024

Checklist

  • I have read through the manual page (man fzf)
  • I have searched through the existing issues
  • For bug reports, I have checked if the bug is reproducible in the latest version of fzf

Output of fzf --version

0.56.2

OS

  • Linux
  • macOS
  • Windows
  • Etc.

Shell

  • bash
  • zsh
  • fish

Problem / Steps to reproduce

Thank you for the great work!

In my .zshrc, I set FZF_COMPLETION_TRIGGER='`'. With up to 0.56.0 installed, this works well (and has for years).

Starting in 0.56.1 and still existing in 0.56.2, this no longer works. When I type for example cd `<TAB>, nothing happens. If I set the env var to nearly anything else, it works again.

If I downgrade to 0.56.0, it works again.

The fzf portion of my .zshrc: https://github.com/jefferickson/dotfiles/blob/d552e8eae75edd1ce4d14b11ae960a9aeccb370a/.zshrc#L96-L106

@LangLangBart
Copy link
Contributor

LangLangBart commented Nov 11, 2024

Thanks for the report. I can reproduce it; the issue lies with the words array
parameter provided by zsh.

fzf/shell/completion.zsh

Lines 124 to 129 in 215ab48

__fzf_extract_command() {
setopt localoptions noksh_arrays
# Control completion with the "compstate" parameter, insert and list noting
compstate[insert]=
compstate[list]=
cmd_word="${words[1]}"

When the trigger consists of only one back-tick, the words array is empty.

For now, you could modify your shell setup in your zshrc by commenting out
this line, though it's not recommended because the actual command you use for
your completion will not be correctly identified, and just fallback to the default.

[[ -z "$cmd_word" ]] && return


It's better to use a different trigger. The construction of the words array is
hardcoded in the C part, and it seems the parser has trouble correctly
identifying a word in this situation (tentatively hinting at a bug in zsh).

# Use ~~ as the trigger sequence instead of the default **
export FZF_COMPLETION_TRIGGER='~~'
# Two back-ticks seems to work 
export FZF_COMPLETION_TRIGGER='``'

It would be possible to fall back to the old extraction method (prior to the PR
linked below) if the words array is empty and the LBUFFER is not, to at
least provide the user with a partial solution. However, this approach would
only work for the first command.

@jefferickson
Copy link
Author

Thank you for the detailed response. I'd like to find a way to keep the backtick as my trigger as I have 6+ years of muscle memory and it's very convenient as it's right next to the TAB on an American layout. Alternatively, I can stay at version 0.56.0 for the time being.

@mathieu-lemay
Copy link

I'm using ;; as a completion trigger and it is also not working anymore, since 0.56.1.

@LangLangBart
Copy link
Contributor

LangLangBart commented Nov 12, 2024

I'd like to find a way to keep the backtick as my trigger

Right, any solution should allow the same characters that can be used in bash
to maintain consistent behavior between both shells.

EDIT: However, it turns out that bash ignores these characters as well, which
contradicts my earlier statement about maintaining consistent behavior between
both shells, as I assumed bash could use such a trigger. Since some zsh users
are used to these triggers, we might just try to add them back.

I'm using ;; as a completion trigger and it is also not working anymore, since 0.56.1.

Characters found to cause issues are these:

Symbol Common Name ASCII Occurrences in Public Git Repos
& Ampersand 38 1
; Semicolon 59 ~25
[ Left Bracket 91 1
` Back-tick 96 ~20
| Pipe 124 0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants