diff --git a/module/PowerShellEditorServices/Commands/Public/Import-EditorCommand.ps1 b/module/PowerShellEditorServices/Commands/Public/Import-EditorCommand.ps1 index e57823a3f..0a60dddeb 100644 --- a/module/PowerShellEditorServices/Commands/Public/Import-EditorCommand.ps1 +++ b/module/PowerShellEditorServices/Commands/Public/Import-EditorCommand.ps1 @@ -57,14 +57,11 @@ function Import-EditorCommand { return $moduleInfo.ExportedFunctions.Values } } - $flags = [Reflection.BindingFlags]'Instance, NonPublic' - $extensionService = $psEditor.GetType(). - GetField('extensionService', $flags). - GetValue($psEditor) - - $editorCommands = $extensionService.GetType(). - GetField('editorCommands', $flags). - GetValue($extensionService) + $editorCommands = @{} + + foreach ($existingCommand in $psEditor.GetCommands()) { + $editorCommands[$existingCommand.Name] = $existingCommand + } } process { switch ($PSCmdlet.ParameterSetName) {