dahlbyk / posh-git

A PowerShell environment for Git
http://dahlbyk.github.io/posh-git/
MIT License
7.69k stars 801 forks source link

Tab auto-complete regression #733

Closed ExE-Boss closed 4 years ago

ExE-Boss commented 4 years ago

System Details

Issue Description

PR #711 caused a regression that broke tab completion on PowerShell >= 6, causing:

git <command> \t

To incorrectly expand to:

git <command> <command>

Instead of what it expanded to in commit https://github.com/dahlbyk/posh-git/commit/89dafc1f37d9a44917d5ce6a84e889e54c6f98b9, which is what I was forced to roll back to.

rkeithhill commented 4 years ago

What do you get from the built-in argument completion for cd ~; gci \w? And what do you get for git <command> .\t?

rkeithhill commented 4 years ago

Also, do you have a specific repro because I haven't been able to repro what you are seeing?

eXpl0it3r commented 4 years ago

Not sure if it's actually an regression, currently the new git command git switch <branch> doesn't work with tab-completion though.

rkeithhill commented 4 years ago

If you git clone the repo, it has support for git switch. Has had it for a few months now. But we haven't published a new beta in almost a year and I'm not sure when the next beta will be published. I recommend that you git clone this repo and import the module by path.

theaquamarine commented 4 years ago

Would you be open to an update to 0.x that adds support for switch and restore?

rkeithhill commented 4 years ago

Yes and no. Obviously adding features to 0.x would help folks but I'd really like to "nudge" folks to 1.0. That said, 1.0 is still beta so that's hard to do until we release a stable version of v1. Supporting multiple versions is not ideal when we have such a small set of folks trying to maintain this module. Whining aside ;-), I would accept a PR to add that functionality to 0.x but who knows when a new version of 0.x would be published.

cdonnellytx commented 4 years ago

I dug into this a bit... the main issue is that the handler for Register-ArgumentCompleter returns the "Text" for an autocomplete as git <command> with no trailing space, instead of the expected git <command> with at least one trailing space. The regexes in GitTabExpansionInternal expect at least one space after the command.

An annoying side-effect of this is that Register-ArgumentCompleter completions aren't unregistered if you unload the module, meaning debugging involves having to open a new PowerShell process for each attempt at debugging.

rkeithhill commented 4 years ago

@cdonnellytx Thanks for taking the time to debug this. If Register-ArgumentCompleter is removing the space between the command and the tab, then there's a challenge - how do we distinguish git checkout \t from git che\t? Perhaps the space still exists in one of arg completer params?