PowerShell / vscode-powershell

Provides PowerShell language and debugging support for Visual Studio Code
https://marketplace.visualstudio.com/items/ms-vscode.PowerShell
MIT License
1.68k stars 479 forks source link

git cannot bring up VScode diff tool under powershell ISE #4908

Closed jdai closed 6 months ago

jdai commented 6 months ago

Prerequisites

Summary

when use "git difftool", on PS it pops up vscode and works well, or PS ISE it doesn't pop up vscode and stuck.

this case might similar as: https://github.com/PowerShell/vscode-powershell/issues/4012

OS Name Microsoft Windows 11 Enterprise Version 10.0.22631 Build 22631

PowerShell Version

PS E:\repos\king> $PSVersionTable; $Host

Name                           Value                                                                                                                                    
----                           -----                                                                                                                                    
PSVersion                      5.1.22621.2506                                                                                                                           
PSEdition                      Desktop                                                                                                                                  
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}                                                                                                                  
BuildVersion                   10.0.22621.2506                                                                                                                          
CLRVersion                     4.0.30319.42000                                                                                                                          
WSManStackVersion              3.0                                                                                                                                      
PSRemotingProtocolVersion      2.3                                                                                                                                      
SerializationVersion           1.1.0.1                                                                                                                                  

Name             : Windows PowerShell ISE Host
Version          : 5.1.22621.2506
InstanceId       : b41bcafd-56c2-4c89-b635-42369ab60fcb
UI               : System.Management.Automation.Internal.Host.InternalHostUserInterface
CurrentCulture   : zh-CN
CurrentUICulture : en-US
PrivateData      : Microsoft.PowerShell.Host.ISE.ISEOptions
DebuggerEnabled  : True
IsRunspacePushed : False
Runspace         : System.Management.Automation.Runspaces.LocalRunspace

Visual Studio Code Version

PS E:\repos\king> code --version
1.85.2
8b3775030ed1a69b13e4f4c628c612102e30a681
x64

Extension Version

PS E:\repos\king> code --list-extensions --show-versions | Select-string powershell

ms-vscode.powershell@2024.0.0

Steps to Reproduce

1)start powershell ISE 2)setup vscode/git env, touch one for file that is in git repo(say file1.txt) then edit .gitconfig by: PS> config --global -e ......#add these lines below: [diff] tool = vscode [difftool "vscode"] cmd = code --wait --diff $LOCAL $REMOTE [merge] tool = vscode [mergetool "vscode"] cmd = code --wait $MERGED 3)run: PS E:\repos\king> git difftool

Viewing (1/1): 'tools/pwsh/modules/Build-Utils.psm1' git difftool PS E:\repos\king> git difftool then stuck.

On PS(not ISE), same command will lead to: PS E:\repos\king> git difftool

Viewing (1/1): 'tools/pwsh/modules/Build-Utils.psm1' Launch 'vscode' [Y/n]? type S and it will continue to pop up vscode window. both PS and PS ISE run as admin.

Visuals

No response

Logs

No response

JustinGrote commented 6 months ago

Thanks for the submission! But if I'm reading this right, you're trying to run PowerShell ISE and then start vscode from ISE? This all works just fine from a cmd or pwsh command prompt so if it doesn't work in ISE there's not much we can do about this in terms of the extension, PowerShell ISE is deprecated.

I have my git configured to use vscode and that is configured for code --wait and works just fine in cmd, bash, and pwsh image

JustinGrote commented 6 months ago

I was able to reproduce in ISE, this has to do with how the custom ISE host is probably handling the interactive prompt of Launch vscode [y/n]. Unfortunately that's nothing we can fix here, we recommend you use VSCode with the PowerShell extension, it is the currently supported official way to author PowerShell. This would have to be fixed in ISE and that's deprecated so unlikely unless something was fixed in git directly to handle this maybe it's unlikely.

image

As such I'm going to close this as wontfix. Sorry, but there's nothing we can do to fix this, it's not in the scope of the vscode extension.

jdai commented 6 months ago

thanks for fast review. I am involved in Microsoft projects and we still use PS ISE. PS has one problem - ninja problem as I filed here: https://github.com/ninja-build/ninja/issues/2379

JustinGrote commented 6 months ago

Sorry to hear that, as a workaround you can have a normal powershell window next to your ISE and whenever you need to do a diff, run the command there rather than ISE, should work fine. If there's a git config setting to disable that prompt, that would probably work too.