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

File operations should consider adding quotes when dealing with spaces #2681

Open
martin-braun opened this issue Feb 20, 2024 · 1 comment
Open
Labels

Comments

@martin-braun
Copy link

Is this a question?
Please start a new Q&A discussion instead of raising a feature request.

Can this functionality be implemented utilising API?
No, and it would make sense to change this for a better default behavior.

Is your feature request related to a problem? Please describe.
When hitting . while being on an object in the tree, it will enter command mode while having the absolute path already inserted. This is nice and all, until the absolute path contains spaces.

Describe the solution you'd like
I think it would make sense to surround the path with quotes by default to circumvent the problem.

Describe alternatives you've considered
Inserting it on my own, but it feels repetitive.

Additional context
It should be discussed if quotes can cause any problems. I only ever use this feature to launch OS specific commands with bang, so I don't know.

@alex-courtis
Copy link
Member

That would be a good enhancement.

Surrounding the path with quotes is arguably non-breaking.

vim.fn.fnescape or similar could be used, although it may not work on some OS variants such as windows powershell.

Alternative: user optionally provides a function to escape the absolute path, something like:

node.run.cmd({opts})                            *nvim-tree-api.node.run.cmd()*
    Enter |cmdline| with the full path of the node and the cursor at the start
    of the line.

    Parameters: ~{opts} (table) optional parameters

    Options: ~{format} (fun(absolute_path: string): string)  format the path before
                                                       inserting

@alex-courtis alex-courtis added the API API or Event label Feb 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants