-
Notifications
You must be signed in to change notification settings - Fork 511
Recent updates, OS and or VSCode breaks integrated scripting environment. #1187
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
Comments
Your example function runs fine on my machine under the PowerShell integrated terminal by selecting all the code and hitting F8: The errors you show with Which right now, does not work. I'm not sure if there is another issue on supporting this exact ability or not, it may be tied into the fact that multi-line support is limited in the extension's terminal. |
Thanks for getting back and the comments. Yet, your assumptions are not valid. This code was directly typed in not copy/paste. That is not something I do in VSCode, ever. The code runs fine in the console host using F5/F8, just not in the integrated with F5/F8. I have been using Monad/PowerShell/ISE and VSCode since their release and even teach courses / workshops on the topics. Full disclosure: I've been teaching IT Pro/Dev courses since 2000 as an MCT and been in IT since the late 1970's. So, you know, not a newbie at this stuff. Not saying I know everything, but well, you know. I have multiple machines in my labs all running PoSH/VSCode, and many are used for the Windows Insider programs and other testing, so are all pristine systems, no other extensions, other than the PowerShell one. This is my main machine, daily dev/admin/class delivery workstation. On one of the recent VSCode updates, it continually prompted me to install git, which I do not use form this system. I finally decided to install it and from that day forward, F5/F8 on any code typed in, or opening an saved .ps1 with functions in it fail to run with F5/F8. I have not changed this environment, added / removed any other software - tools, in more than a year. This F5/F8 issue in the integrated environment, is a recent thing. All was working as designed as of December 2017. Sometime in Jan - today, something, from some update, OS or VScode, has broken this feature on this system. It's the only one I regularly keep updated with any update OS/VSCode that comes out and have more extensions on for daily work and workshops/classes I deliver. This is beginning to look like I will need to flatten and rebuild this machine, Just to get VSCode back to normal, since despite all my rollback, uninstalls / reinstalls, registry cleans, etc. have not fixed it. A very ugly proposition, or just never try to run code in the VSCode integrated editor ever again or spin up a separate pristine VM, just to be able to use VSCode again. Another ugly proposition. I am just trying to get all things back to normal and after a week, of troubleshooting this thing, I felt it prudent to report, not only for me but just in case others hit this wall. |
Update on troubleshooting... PowerShell Integrated Console When the same function sample is all on one line --- success function new-test ($name){ $name } Results PS C:\Users\postanote> function new-test ($name){ $name } Moving the braced variable to a new line --- errors function new-test ($name) PS C:\Users\postanote> function new-test ($name) Putting the variable on it's own line --- errors as before function new-test ($name) PS C:\Users\postanote> function new-test ($name)
So, something about the integrated environment is corrupt. Argh!!! function FunctionName ($OptionalParameters){'hello'} PS C:\Users\postanote> function FunctionName ($OptionalParameters){'hello'} function FunctionName ($OptionalParameters) PS C:\Users\postanote> function FunctionName ($OptionalParameters) Just not sure what. 8^{ |
Finally found the issue in an unexpected place while comparing one of my pristine VM's to my main daily machine. Looking at every default and user config one line at a time. Root cause to this dilemma. --- *** Default Key bindings. *** updates!!! In earlier versions of VSCode, there was not a default option to run PowerShell Selected text, like we could with the Windows PowerShell ISE. So, creative people suggest adding a key binding at the Workbench level. https://blogs.technet.microsoft.com/heyscriptingguy/2016/12/07/make-visual-studio-code-more-like-the-integrated-scripting-environment/ Which I called, 'Run selected Text in the Active Terminal' Which I did of course and all things hummed along as expected. Well, in the wisdom of I guess someone on the PowerShell Dev team. Some enterprising person(s) added this ('let's make this VSCode ISE a bit more on par with the Windows PowerShell ISE') now to the default keybindings. Well, that little optimization ended up, conflicting with my previous user key binding. So, now I had my user key binding as noted above and a new key binding for the same hotkey called 'Run Selection'. Greaaate!, just greaaate! So, the VSC ISE was now confused. I guess trying to run both on F8. Now that still did not explain the F5 wonkiness, but whatever. So, deleted my custom F8 Keybinding, and all things appear to be back to normal from that perspective. PowerShell Integrated Console PS C:\Users\postanote> function new-tester ($name) { Wow, just Wow. Moral of the story folks, is to make sure you read every line of the ReadMe on new releases as to not get bitten by customizations you had to do, before new features or modified features ensue. Oh well, live and learn. Still, odd that it would run correctly as long as all things were on one line. But oh well. |
Thank you postanote, the issue showed up for my after installing and using Powershell 7. recently, Dr. Scripto's insight and your saved me from future frustration. |
The integrated scripting environment will not run any function block code.
This started as of the last few VScode and OS updates.
Complete uninstall, reinstalls done, multiple times, using ia32 and x64 versions after manual registry cleanup of all VScode, Visual Studio Code keys and data.
Sample quick function
function new-test ($name)
{
$name
}
new-test -name 'tester'
(Get-CimInstance -ClassName CIM_OperatingSystem).Caption
$Host
code -v
$pseditor.EditorServicesVersion
code --list-extensions --show-versions
$PSVersionTable
The text was updated successfully, but these errors were encountered: