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

powershell_completions.go - Not Completing File Path #1961

Closed
mattcargile opened this issue May 17, 2023 · 3 comments
Closed

powershell_completions.go - Not Completing File Path #1961

mattcargile opened this issue May 17, 2023 · 3 comments

Comments

@mattcargile
Copy link

It would be nice if I could get completions for file paths because of programs like glow.exe which require it. It appears based on this code that it is by design? I would expect default completion to a file path.

if (($Directive -band $ShellCompDirectiveNoFileComp) -ne 0 ) {
__%[1]s_debug "ShellCompDirectiveNoFileComp is called"
if ($Values.Length -eq 0) {
# Just print an empty string here so the
# shell does not start to complete paths.
# We cannot use CompletionResult here because
# it does not accept an empty string as argument.
""
return
}
}

It is discussed a little below.

charmbracelet/glow#457

@Luap99
Copy link
Contributor

Luap99 commented May 22, 2023

If ShellCompDirectiveNoFileComp is set the program explicitly requested that no path completion should be done. If ShellCompDirectiveNoFileComp is not set then it should complete paths, it has been a long time since I used powershell but this at least used to work correctly.

Reading your linked issue it seems like the issue is for other shells as well so guess this is a problem with your program not cobra itself.

@mattcargile
Copy link
Author

I still think it is cobra. Usage like oh-my-posh.exe file + <TAB> won't complete file paths either.

Maybe glow needs the newest cobra build. Usage like oh-my-posh.exe init powershell file + <TAB> does work so I'm not sure how it is working. oh-my-posh only needs to pull from files on certain sub commands while glow + <TAB> for file paths is more natural?

@mattcargile
Copy link
Author

So I am closing this and opening the below because I think it can be solved with the below usage.

https://github.com/spf13/cobra/blob/284f4101043c4b1faebde411caec35a7b6e36494/active_help.md#adding-active-help-messages

And I opened the below in the main repo. Thanks @Luap99

charmbracelet/glow#512

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

2 participants