diff --git a/module/PowerShellEditorServices/Commands/Public/CmdletInterface.ps1 b/module/PowerShellEditorServices/Commands/Public/CmdletInterface.ps1 index 5f7f1bdfb..47623296a 100644 --- a/module/PowerShellEditorServices/Commands/Public/CmdletInterface.ps1 +++ b/module/PowerShellEditorServices/Commands/Public/CmdletInterface.ps1 @@ -136,6 +136,11 @@ function New-EditorFile { $preview = $true } + # Resolve full path before passing to editor + if (!([System.IO.Path]::IsPathRooted($fileName))) { + $fileName = $ExecutionContext.SessionState.Path.GetUnresolvedProviderPathFromPSPath($fileName) + } + $psEditor.Workspace.OpenFile($fileName, $preview) $psEditor.GetEditorContext().CurrentFile.InsertText(($valueList | Out-String)) } else {