From 6398c5db9eee4d4d98072b7bbb4d689be20cb22e Mon Sep 17 00:00:00 2001 From: Tyler Leonhardt Date: Tue, 2 Apr 2019 20:07:04 -0700 Subject: [PATCH 1/2] Fix New-EditorFile with no folder or no files open --- .../Commands/Public/CmdletInterface.ps1 | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/module/PowerShellEditorServices/Commands/Public/CmdletInterface.ps1 b/module/PowerShellEditorServices/Commands/Public/CmdletInterface.ps1 index 5f7f1bdfb..59a93b0a6 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 = (Resolve-Path $fileName).Path + } + $psEditor.Workspace.OpenFile($fileName, $preview) $psEditor.GetEditorContext().CurrentFile.InsertText(($valueList | Out-String)) } else { From a89cda88f826c6493d835d32acaf72b54358145b Mon Sep 17 00:00:00 2001 From: Tyler Leonhardt Date: Mon, 8 Apr 2019 13:19:36 -0700 Subject: [PATCH 2/2] address rob's feedback --- .../Commands/Public/CmdletInterface.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/module/PowerShellEditorServices/Commands/Public/CmdletInterface.ps1 b/module/PowerShellEditorServices/Commands/Public/CmdletInterface.ps1 index 59a93b0a6..47623296a 100644 --- a/module/PowerShellEditorServices/Commands/Public/CmdletInterface.ps1 +++ b/module/PowerShellEditorServices/Commands/Public/CmdletInterface.ps1 @@ -138,7 +138,7 @@ function New-EditorFile { # Resolve full path before passing to editor if (!([System.IO.Path]::IsPathRooted($fileName))) { - $fileName = (Resolve-Path $fileName).Path + $fileName = $ExecutionContext.SessionState.Path.GetUnresolvedProviderPathFromPSPath($fileName) } $psEditor.Workspace.OpenFile($fileName, $preview)