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

Unexpected filename completion behavior with carapace #2035

Open
lzybkr opened this issue Nov 20, 2023 · 3 comments
Open

Unexpected filename completion behavior with carapace #2035

lzybkr opened this issue Nov 20, 2023 · 3 comments
Labels
enhancement New feature or request

Comments

@lzybkr
Copy link

lzybkr commented Nov 20, 2023

Request

I'm using carapace on Windows with PowerShell, not sure if the issues I'm seeing are relevant elsewhere.

Filename completion works inconsistently when using carapace versus not.

Example:

notepad c:\winTab

Versus:

nvim c:\winTab

The former will complete to C:\Windows whereas the later doesn't complete anything.

Proposed solution

carapace should try to match the shell's native completion matching.

In general, if the completion is expecting a filename but the only valid matches are directories, carapace should complete directories.
On Windows, filenames are case insensitive so carapce should ignore case.

Maybe not the best option but for many commands like nvim where carapace may get in the way of returning useful results, just return nothing and let the default PowerShell completion fallback take over.

For other commands like git, this might not be a great option and result in an inconsistent experience, so I would at least consider trying to match the shell's behavior somewhat.

Anything else?

No response

@lzybkr lzybkr added the enhancement New feature or request label Nov 20, 2023
@lzybkr
Copy link
Author

lzybkr commented Nov 20, 2023

A couple more issues I've observed:

  • Use of \ on Windows unexpectedly results in no matches
  • Use of wildcards also results in no matches

Examples:

nvim C:\Windows\wTab

nvim C:/Windows/*wTab

@rsteube
Copy link
Member

rsteube commented Nov 21, 2023

Backslash filepaths are indeed not supported in carapace.
Other shells use forward slash and Powershell can do so as well.
Maybe in the future, but for now there is no plan to add it.

Wildcard expansion is also not supported.
There are some options for globbing.
But often there is not differentiation possible between quoted/escaped globs and those that aren't.
There is a similar issue with ~ wich is simply assumed unquoted when it prefixes a path.

Carapace intentionally has no file completion fallback.
This only seems helpful because shell completions so far were often incomplete.
Most of the time it is simply wrong.

Carapace does its own file completion as:

  • it ensures consistency between shells
  • allows highlighing with LS_COLORS
  • supports directory changes (git -C ../other-dir add <file in other-dir>)
  • allows prefixing like file://<path> and key=<path>
  • makes embedding possible with a clear interface

@rsteube
Copy link
Member

rsteube commented Nov 21, 2023

In general, if the completion is expecting a filename but the only valid matches are directories, carapace should complete directories.

This should actually be already the case (see ActionFiles and ActionDirectories)

On Windows, filenames are case insensitive so carapce should ignore case.

Generic case-insensitive matching can be enabled: #1791

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

No branches or pull requests

2 participants