diff --git a/module/PowerShellEditorServices/Commands/Public/CmdletInterface.ps1 b/module/PowerShellEditorServices/Commands/Public/CmdletInterface.ps1 index 6fc9114e6..e54089d91 100644 --- a/module/PowerShellEditorServices/Commands/Public/CmdletInterface.ps1 +++ b/module/PowerShellEditorServices/Commands/Public/CmdletInterface.ps1 @@ -155,7 +155,7 @@ function New-EditorFile { } $psEditor.Workspace.OpenFile($fileName, $preview) - $editorContext.CurrentFile.InsertText(($valueList | Out-String)) + $psEditor.GetEditorContext().CurrentFile.InsertText(($valueList | Out-String)) } else { $PSCmdlet.WriteError( ( New-Object -TypeName System.Management.Automation.ErrorRecord -ArgumentList @( @@ -167,7 +167,7 @@ function New-EditorFile { } } else { $psEditor.Workspace.NewFile() - $editorContext.CurrentFile.InsertText(($valueList | Out-String)) + $psEditor.GetEditorContext().CurrentFile.InsertText(($valueList | Out-String)) } } } diff --git a/module/PowerShellEditorServices/Commands/Public/Out-CurrentFile.ps1 b/module/PowerShellEditorServices/Commands/Public/Out-CurrentFile.ps1 index a8d222e97..bc7bfcba1 100644 --- a/module/PowerShellEditorServices/Commands/Public/Out-CurrentFile.ps1 +++ b/module/PowerShellEditorServices/Commands/Public/Out-CurrentFile.ps1 @@ -26,7 +26,7 @@ function Out-CurrentFile { try { # If there is no file open - $psEditor.GetEditorContext() + $null = $psEditor.GetEditorContext() } catch { # create a new one