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

Tab completion incorrectly re-escapes already escaped path #114

Open
erhhung opened this issue Dec 4, 2024 · 0 comments
Open

Tab completion incorrectly re-escapes already escaped path #114

erhhung opened this issue Dec 4, 2024 · 0 comments

Comments

@erhhung
Copy link

erhhung commented Dec 4, 2024

Here are some directories and files on a macOS system
(only showing entries as examples relevant to this issue):

~/Library/
    Application\ Scripts/
    Application\ Support/
        .DS_Store
        AddressBook
        App\ Store
        AskPermission
        DVD\ Player

I have the latest .fzf_bash_completion script loaded—although the issue has been around for quite some time—and I have neither of the auto common prefix options (FZF_COMPLETION_AUTO_COMMON_PREFIX and FZF_COMPLETION_AUTO_COMMON_PREFIX_PART) defined, so base completion behavior...

$ ls ~/Lib<tab>
This works fine as there's only one match.
$ ls ~/Library/(cursor after added slash)

$ ls ~/Library/<tab>
Popup appears with entries. For example:

> ls ~/Library/
─────────────────────────────────
▶ ~/Library/.DS_Store
  ~/Library/.localized
  ~/Library/Accessibility/
  ~/Library/Accounts/
  ~/Library/AppleMediaServices/
  ~/Library/Application\ Scripts/
  ~/Library/Application\ Support/
  ~/Library/Assistant/
  ~/Library/Assistants/

Note that Application\ Support/ is backslash-escaped in the list.

FWIW, I also use Amazon Q CLI autocomplete, and names containing spaces are shown not-escaped in their popup, i.e. Application Support/

I choose ~/Library/Application\ Support/ and hit Enter.
$ ls ~/Library/Application\ Support/(cursor immediately after slash)
So far so good, so I just hit Tab again.

$ ls ~/Library/Application\ Support/<tab>
Popup appears with bad entries. For example:

> ls ~/Library/Application\ Support/
────────────────────────────────────────────────
▶ ~/Library/Application\\\ Support/.DS_Store
  ~/Library/Application\\\ Support/AddressBook
  ~/Library/Application\\\ Support/App\ Store
  ~/Library/Application\\\ Support/AskPermission
  ~/Library/Application\\\ Support/DVD\ Player

Note that the existing path is now re-escaped ("\ " becomes "\\\ ") while base entry names are only backslash-escaped as needed, like before.

I choose ~/Library/Application\\\ Support/App\ Store and hit Enter.
$ ls ~/Library/Application\\\ Support/App\ Store (cursor after space but no slash)
If I hit Enter now, I obviously get "No such file or directory"

I would have expected to see:
$ ls ~/Library/Application\ Support/App\ Store/(cursor immediately after slash)

@erhhung erhhung changed the title Tab completion incorrectly re-escapes already escaped spaces Tab completion incorrectly re-escapes already escaped path Dec 4, 2024
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

No branches or pull requests

1 participant