From cf9fc1d3cb8f7b840186b3a605ca9e2689397e97 Mon Sep 17 00:00:00 2001 From: Michael Kelley Date: Fri, 2 Feb 2024 08:00:43 -0800 Subject: [PATCH] Get-EditorLaunch returns a cmd line for unknown editor - $env:EDITOR and $ENV:VISUAL are now respected properly if the editor is unknown - Resolves #246 --- PSFzf.Functions.ps1 | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/PSFzf.Functions.ps1 b/PSFzf.Functions.ps1 index acfc61d..3d58384 100644 --- a/PSFzf.Functions.ps1 +++ b/PSFzf.Functions.ps1 @@ -86,6 +86,15 @@ function Get-EditorLaunch() { "$editor$editorOptions +{1} ""{0}""" -f $(Resolve-Path $FileList.Trim('"')), $LineNum } } + else { + # select the first file as we don't know if the editor supports opening multiple files from the cmd line + if ($FileList -is [array] -and $FileList.length -gt 1) { + "$editor$editorOptions ""{0}""" -f $(Resolve-Path $FileList[0].Trim('"')) + } + else { + "$editor$editorOptions ""{0}""" -f $(Resolve-Path $FileList.Trim('"')) + } + } } function Invoke-FuzzyEdit() { param($Directory = ".", [switch]$Wait)