Closed ArtisanByteCrafter closed 4 years ago
I've made some changes to the v0.5.0 branch to accommodate the new PowerShellEditorServices architecture. That version is a complete overhaul of the module and isn't where I want it to be for release yet, but it's currently functional and should serve as a drop in replacement.
You can grab a daily here
Edit 2020/02/08: Updated for PowerShellEditorServices 2.0.0-preview.8
Edit 2020/02/22: Updated for PowerShellEditorServices 2.0.0-preview.9
There's a few new editor commands in there, some fixes to old ones, and a lot more configuration options. There's also a context based refactor system similar to "quick fixes" or "code actions". To use that, put something like this in your keybindings.json
:
{
"key": "ctrl+.",
"command": "PowerShell.InvokeRegisteredEditorCommand",
"args": { "commandName": "Invoke-DocumentRefactor" },
"when": "editorLangId == 'powershell'",
},
And then press Ctrl + . on whatever you want to refactor.
There's also configuration options scoped to machine, user, or project levels. To create a new settings file, use New-CommandSuiteSettingsFile
with either -Scope Machine
(or User) or -Path
for project. (@markekraus this includes the splat variable name config)
Daily works great @SeeminglyScience - thank you so much for publishing the link as a temporary workaround!
Any chance the v 0.5.0 can be pushed to the Gallery as a prelease?
@kilasuit Not yet, PowerShellEditorServices is currently changing too rapidly to steadily release previews atm.
Once PowerShell/PowerShellEditorServices#1183 makes it into a vscode-powershell preview release then I'll get something up.
After today's update to Preview 0.5 stopped working again.
Import-Module -Name EditorServicesCommandSuite 149,03ms
Add-Type : Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information.
At C:\Program Files\WindowsPowerShell\Modules\EditorServicesCommandSuite\0.5.0\EditorServicesCommandSuite.psm1:15 char:9
+ Add-Type -Path "$PSScriptRoot/EditorServicesCommandSuite.Edit ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Add-Type], ReflectionTypeLoadException
+ FullyQualifiedErrorId : System.Reflection.ReflectionTypeLoadException,Microsoft.PowerShell.Commands.AddTypeCommand
The following exception occurred while retrieving member "GetCommandSuite": "Could not load type 'Microsoft.PowerShell.EditorServices.Servic
es.PowerShellContext.EditorObject' from assembly 'Microsoft.PowerShell.EditorServices, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null
'."
At C:\Program Files\WindowsPowerShell\Modules\EditorServicesCommandSuite\0.5.0\EditorServicesCommandSuite.psm1:19 char:5
+ $CommandSuite = $type::GetCommandSuite(
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], ExtendedTypeSystemException
+ FullyQualifiedErrorId : CatchFromBaseGetMember
Get-RefactorOption : No existing CommandSuite instance was found. Initialization with the host editor may have failed.
At C:\Program Files\WindowsPowerShell\Modules\EditorServicesCommandSuite\0.5.0\EditorServicesCommandSuite.psm1:53 char:9
+ Get-RefactorOption | ForEach-Object {
+ ~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (:) [Get-RefactorOption], NoCommandSuiteInstanceException
+ FullyQualifiedErrorId : NoCommandSuiteInstance,EditorServicesCommandSuite.Commands.GetRefactorOptionCommand
Import-EditorCommand -Module EditorServicesCommandSuite
Unable to find type [Microsoft.PowerShell.EditorServices.Services.PowerShellContext.EditorCommand].
At C:\Users\przemyslaw.klys\.vscode\extensions\ms-vscode.powershell-preview-2020.2.0\modules\PowerShellEditorServices\Commands\Public\Import
-EditorCommand.ps1:10 char:17
+ ... [OutputType([Microsoft.PowerShell.EditorServices.Services.PowerShellC ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (Microsoft.Power...t.EditorCommand:TypeName) [], RuntimeException
+ FullyQualifiedErrorId : TypeNotFound
Thanks @PrzemyslawKlys! Yeah, some more big changes. I'll get another build ready this weekend.
Fix for preview 9 here. Also updated the link above.
Unable to find type [Microsoft.PowerShell.EditorServices.Services.PowerShellContext.EditorCommand].
At C:\Users\przemyslaw.klys\.vscode\extensions\ms-vscode.powershell-preview-2020.2.0\modules\PowerShellEditorServices\Commands\Public\Import
-EditorCommand.ps1:10 char:17
+ ... [OutputType([Microsoft.PowerShell.EditorServices.Services.PowerShellC ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (Microsoft.Power...t.EditorCommand:TypeName) [], RuntimeException
+ FullyQualifiedErrorId : TypeNotFound
One error still remains.
@PrzemyslawKlys That error isn't coming from ESCS, can you file that on PowerShellEditorServices? Also you can remove Import-EditorCommand
from your profile, it's no longer required for this module (and that'll bypass that error).
I can, but does it still matter if I'm not supposed to use it?
This module just doesn't require it anymore, other modules still can. I'll take submitting the issue, thanks for the report 🙂
Fixed with v1.0.0-beta1
Install-Module EditorServicesCommandSuite -Scope CurrentUser -AllowPrerelease -Force
Working with the newest Powershell Preview extension (tested on v2019.11.0),
ConvertTo-SplatExpression
fails with the following error. Non-preview powershell extension works as intended.