Skip to content

Commit 821905f

Browse files
sk82jackTylerLeonhardt
authored andcommitted
Fix Import-EditorCommand -Module (#1114)
* Fix extension service field name * Get editor commands using API instead of reflection
1 parent d48438c commit 821905f

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

module/PowerShellEditorServices/Commands/Public/Import-EditorCommand.ps1

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -57,14 +57,11 @@ function Import-EditorCommand {
5757
return $moduleInfo.ExportedFunctions.Values
5858
}
5959
}
60-
$flags = [Reflection.BindingFlags]'Instance, NonPublic'
61-
$extensionService = $psEditor.GetType().
62-
GetField('extensionService', $flags).
63-
GetValue($psEditor)
64-
65-
$editorCommands = $extensionService.GetType().
66-
GetField('editorCommands', $flags).
67-
GetValue($extensionService)
60+
$editorCommands = @{}
61+
62+
foreach ($existingCommand in $psEditor.GetCommands()) {
63+
$editorCommands[$existingCommand.Name] = $existingCommand
64+
}
6865
}
6966
process {
7067
switch ($PSCmdlet.ParameterSetName) {

0 commit comments

Comments
 (0)