-
Notifications
You must be signed in to change notification settings - Fork 510
Register-EditorCommand
appears broken in preview release
#3691
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Register-EditorCommand
appears broken in preview release
#3691
Comments
Thanks for the detailed information! @NJK-HOME We appreciate the screenshots and steps to repro! We will investigate fixing this |
@SydneyhSmith we need to determine if this is still reproducing, if so, we need to fix it. |
@andschwa I can reproduce this on latest preview, although I wonder if there's a chance the other host work you have done will cause the command to return--if I have time I'll test on lastest build |
@JustinGrote I wonder if solving this will solve #3807 |
Register-EditorCommand
appears broken in preview release
@SeeminglyScience Easy enough fix, need to interrupt the current prompt lol. |
Thank you. |
You're welcome! Trying to get a preview out right now in fact. |
The fix for this is out in PowerShell Preview v2022.2.2! |
I am not sure what is going on now, but I cannot get my test case to work in either new preview version or the existing production version anymore. Which is weird because I have the above screen shots showing that it did work at one time. The hang is not happening anymore, so I think you fixed that. But I cannot get "Test" to write the screen in any version of the extension now. For my actual use case - that definitely still works in the current version and definitely still fails in the latest release (2022.2.2). But I cannot get the test case of writing "Test" to the terminal to work anywhere now. Between my original post and now, I know that VSCode was updated to version 1.64.x - so maybe that upgrade is partially causing the test case to fail across the board?? At least I have the screen shots to show I am not completely losing my mind :) I might try installing an older version of VSCode to see if I can get it work again... |
OK, for whatever reason my above test case must be flawed and what I originally tried and used for the screenshot is different from what I typed above. Now, I changed it to write a text file to my desktop instead of relying on output to the terminal: Register-EditorCommand -Name SignCurrentScript -DisplayName "Test Command" -ScriptBlock {New-Item -Path $HOME\Desktop\Test.txt -ItemType File} This test case now works in all versions. It successfully creates a text file to the desktop. So now I see the actual problem. In the original version, whenever you ran an editor command it would display "PowerShell" text in the bottom left corner of VSCode. That was my indicator it was running. In the new version, it no longer shows "PowerShell" text so there is no feedback to indicate it is working or not. So I assumed it was failing without doing more investigation to see if it actually worked. This is my fault and offer my apologies :( That being said, can we get the "PowerShell" text back as an indicator it is running :) Thanks! |
Yay! Glad to see everything is working for you. The indicator is interesting, I'm not sure how that was wired up in the past. We have some pending work to revamp that whole interface as VS Code is coming out with more explicit APIs for it so that all extensions can match; I imagine we could make it indicate anytime some PowerShell code is running! |
Prerequisites
Summary
I am using the Register-EditorCommand in my "Microsoft.VSCode_profile.ps1" profile and assigning it to the alt-f2 in my key bindings file. When I try this with the latest preview, nothing happens. No error, nothing.
If I add a simple "Register-EditorCommand" to my profile file and then try to execute it with the "PowerShell: Show Additional Commands from PowerShell Modules" it appears to hang and/or never return control to the terminal window.
For example if I have something like this in my profile:
Register-EditorCommand -Name TestCommand -DisplayName "Test Command" -ScriptBlock {Write-Host "Test"}
It would normally display "Test" in the terminal and then return control to the terminal. In the preview version it displays "Test" but never returns control. Not sure if you can tell from the screen shots....the first one is the problem (preview version) and the second one is the older release version that works.

So I am not sure if this is the same problem that is happening with the actual script block I am trying to get to work. But it seems odd that it never returns control to the terminal, but in the release version it does. So at this point I am assuming it is related to the problem.
PowerShell Version
Visual Studio Code Version
Extension Version
Steps to Reproduce
Register-EditorCommand -Name TestCommand -DisplayName "Test Command" -ScriptBlock {Write-Host "Test"}
"PowerShell: Show Additional Commands from PowerShell Modules"
Visuals
No response
Logs
No response
The text was updated successfully, but these errors were encountered: