dahlbyk / posh-git

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

Completion for "git add" no longer suggests changed files #883

Closed thomaslevesque closed 2 years ago

thomaslevesque commented 2 years ago

System Details

(I'm pretty sure the posh-git version is wrong... I installed via PowerShellGet not long ago, and tried to reinstall today, with the same result)

Issue Description

At some point, the completion for git add suggested the paths of modified files. I'm sure it worked, because I used it very frequently. Now it just suggests the names of files and directories in the current directory. I just installed on a different machine, and I'm seeing the same behavior. Not sure when it stopped working...

kjellerstedt commented 2 years ago

This has also stopped working for me since a while back. Would there be any way to toggle the functionality here if the change is intended?

dahlbyk commented 2 years ago

I don't know of anything that has changed in Git or posh-git recently that would cause this.

Can you check the contents of your $GitStatus variable in a project that has modifications? You should see the list of modified/staged files from git status in the Index and Working properties: image

Other tab completion (commands, branch names) is working as expected?

thomaslevesque commented 2 years ago

Interesting... my $GitStatus variable is empty. This seems to be caused by Oh My Posh. If I disable it in my PS profile, the problem disappears. I was under the impression that Oh My Posh used posh-git for git related stuff, but it seems to actually break posh-git...

thomaslevesque commented 2 years ago

OK, got it. To be able to use both posh-git and oh my posh, you just need to set the POSH_GIT_ENABLED environment variable to true in your PowerShell profile:

$env:POSH_GIT_ENABLED = $true

This is documented here.

dahlbyk commented 2 years ago

Glad you figure it out, @thomaslevesque.

@JanDeDobbeleer, can you think of a reason for the posh-git module not to set $env:POSH_GIT_ENABLED on import? Or conversely, would it make sense for oh-my-posh to check $GitPromptSettings.EnablePromptStatus instead of needing to set a separate environment variable?

JanDeDobbeleer commented 2 years ago

@dahlbyk we could do that yes. Allow me to draft something!