dotnet / command-line-api

Command line parsing, invocation, and rendering of terminal output.
https://github.com/dotnet/command-line-api/wiki
MIT License
3.38k stars 381 forks source link

dotnet-suggest doesn't suggest after typing a dash or two #1039

Open tompazourek opened 4 years ago

tompazourek commented 4 years ago

I was trying out dotnet-suggest, and found a very strange thing:

When I type in:

t-rex <TAB>

I get suggestions. But when I type in an extra - or --, I don't get any. If I type in first letter (e.g. --f), I get suggestions again.

It's a very natural thing in PowerShell to type in the name of the command, then a space and a dash, and then start tabbing until you find the parameter you're looking for but can't remember the name of. This doesn't work here and it's frustrating.

Basically, I want suggestions for all these inputs:

t-rex <TAB>
t-rex -<TAB>
t-rex --<TAB>
t-rex --f<TAB>

But I only get for the 1st one, and the 4th one, and that's just so strange and confusing.

jonsequitur commented 4 years ago

Thanks for reporting it.

This appears to be a problem with t-rex specifically (possibly due to an older version of System.CommandLine). In dotnet-interactive for example, this works as expected.

I'll take a closer look.

tompazourek commented 4 years ago

@jonsequitur If I try the dotnet-suggest instead of t-rex, it's still broken, so it doesn't appear as t-rex issue to me.

After some investigation, I found out that it's actually an issue in PowerShell. The registered argument completer doesn't get called at all if you type in just a dash or two dashes. So there's nothing that dotnet-suggest can hook into. Here's their issue for it: https://github.com/PowerShell/PowerShell/issues/2912

It looks like they fixed it in PowerShell Core (I checked it in 7.0.3 and it works fine there), but it's still broken in the classic PowerShell 5.1 that's bundled in Windows 10 😢

jonsequitur commented 4 years ago

Interesting. I can repro the issue with t-rex but not with dotnet-suggest or dotnet-interactive, both in PowerShell Core 7.0.3. And with t-rex, the repro is slightly different from what you reported. t-rex -<TAB> doesn't work at all, and the shell is unresponsive for a few seconds. t-rex --<TAB> is very, very slow, but eventually it produces completions.

tompazourek commented 4 years ago

I see, you might be right that t-rex is a bit broken in both PS Core 7 and PS 5.1.

My point is that all the suggestions are broken in PS 5.1 which is the one that's bundled in Windows by default... It looks like there's nothing to be done about that one though 😞