Posh-git: Tab auto-complete regression

Created on 20 Jan 2020  路  8Comments  路  Source: dahlbyk/posh-git

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.

Most helpful comment

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.

All 8 comments

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

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

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

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.

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

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.

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.

@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?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Alfetta159 picture Alfetta159  路  3Comments

codedog picture codedog  路  7Comments

jpierson picture jpierson  路  9Comments

AnthonyMastrean picture AnthonyMastrean  路  9Comments

nairby picture nairby  路  6Comments