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

[fish] Fix for directories with special characters #4230

Merged
merged 1 commit into from
Feb 8, 2025

Conversation

bitraid
Copy link
Contributor

@bitraid bitraid commented Feb 8, 2025

If the current command line token contained a directory with special characters, the script would fail to detect it.

@junegunn
Copy link
Owner

junegunn commented Feb 8, 2025

Can you mention some test cases in the commit message?

Using CTRL-T or ALT-C when the current command line token contained a
directory with special characters, the script would fail to detect it.
For exampe, an existing directory named `it\'s\ a\ test`, instead of
using it as walker-root, it would use it as the query.
@bitraid
Copy link
Contributor Author

bitraid commented Feb 8, 2025

I added a commit message. Let me know if it needs more info.

@junegunn
Copy link
Owner

junegunn commented Feb 8, 2025

Thanks, I've just tested the code and it does fix the issue.

mkdir "it's a test"
touch "it's a test"/foo
ls it\'s\ a\ test/<CTRL-T>
  # Works as expected

But I noticed a slight difference with bash and zsh's fuzzy completion.

ls it\'s\ a\ t<CTRL-T>
  # Starts fzf with "it\'s\ a\ t"
  # In bash and zsh, `ls it\'s\ a\ t**<TAB>`, starts fzf with "it's a t"

I don't think this is necessarily a problem, because CTRL-T of fish is not supposed to behave identical to them. I'm just wondering how you feel about it.

@bitraid
Copy link
Contributor Author

bitraid commented Feb 8, 2025

This is not a regression from this change. Currently, in fish, the query from the command line token is processed exactly as if it was typed in fzf prompt. So, in this example, only the spaces should be escaped. This allows for less typing and not worrying about escaping and open quotes, but I understand that it can also be confusing, especially if the token for the query was created by the shell's auto-completion. We could probably change that, but I think we would have to use the --is-valid switch of commandline (and, similar to bash and zsh, not bring up fzf on open quotes), which was added in version 3.4.0 of fish. Let me know what you think.

@junegunn
Copy link
Owner

junegunn commented Feb 8, 2025

Considering #4196 and this is not a regression, I think we should merge this as it is now.

@junegunn junegunn merged commit 06c6615 into junegunn:master Feb 8, 2025
5 checks passed
@junegunn
Copy link
Owner

junegunn commented Feb 8, 2025

Merged, thanks again!

@bitraid bitraid deleted the fish-dir-fix branch February 8, 2025 14:03
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 this pull request may close these issues.

2 participants