dahlbyk / posh-git

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

`git add` tab completion cycles over all files #904

Closed puya-ms closed 2 years ago

puya-ms commented 2 years ago

System Details

Issue Description

This may not be related to posh-git but I am hoping someone here may be able to help. When I do:

git add <press tab>

The completion cycles through ALL files in current directory and not just the directory / subdirectories of modified files.

I was wondering if anyone had a similar issue and if so how did they resolve it.

dahlbyk commented 2 years ago

Are you using the posh-git prompt? What does $GitStatus show in a repo with modified files?

puya-ms commented 2 years ago

Are you using the posh-git prompt

@dahlbyk Thank you so issue was that I had my own global:prompt function in the $profile file. However I see that the prompt now only cycles through files that were modified when I entered the git repo directory. Is this a bug? 1- Enter repo directory, say I have file1 and file2 modified 2- git add cycles through file1 and file2 3- modify file3 4- git add still only cycles through file1 and file2

Also is there a way to configure the prompt to show parentdir\currentdir only

dahlbyk commented 2 years ago

However I see that the prompt now only cycles through files that were modified when I entered the git repo directory. Is this a bug?

I suppose you could consider it a bug, but this is how it's always worked. Tab expansion uses the cached $GitStatus to show results faster on tab. If you hit Enter to get a new prompt, you'll get an updated tab expansion list, too.

Also is there a way to configure the prompt to show parentdir\currentdir only

You can set DefaultPromptPath to any string you want the path to expand, e.g. you could define a Get-ParentAndCurrentPath function and set $GitPromptSettings.DefaultPromptPath = '$(Get-ParentAndCurrentPath)'.

Default is the provided Get-PromptPath: https://github.com/dahlbyk/posh-git/blob/5a87e8a196d13395f978d774f80dedb40d43b85e/src/PoshGitTypes.ps1#L283 Which is actually pretty complicated: https://github.com/dahlbyk/posh-git/blob/396d726b69ceff6897897987249593e2034885e3/src/Utils.ps1#L393-L429

puya-ms commented 2 years ago

@dahlbyk Awesome thank you so much!