diff --git a/base/Edit-TextFile.ps1 b/base/Edit-TextFile.ps1 index c57bfdb..4181a5c 100644 --- a/base/Edit-TextFile.ps1 +++ b/base/Edit-TextFile.ps1 @@ -18,16 +18,16 @@ end { $local:editor = $null foreach( $local:testEditor in $editors ) { if( $(try{Get-Command -ListImported -Type Application $testEditor -ErrorAction SilentlyContinue}catch{}) ) { - $editor = $testEditor + $editor = "`"$testEditor`"" break; } } - if( $editor -match 'vim?$' ) { + if( $editor -match 'vim?"$' ) { $editor += ' -p' } - if( $editor -match 'code(\.exe)?$' ) { + if( $editor -match 'code(\.exe)?"$' ) { if( -not (Get-Process -Name 'code' -ErrorAction SilentlyContinue) ) { Invoke-ExpressionEx -sudo:$sudo $editor } @@ -39,6 +39,6 @@ end { if( $Path ) { $arguments = "$arguments" } if( $PSCmdlet.ShouldProcess( "Edit ($editor): $arguments" ) ) { - Invoke-ExpressionEx -sudo:$sudo "& `"$editor`"" "$arguments" + Invoke-ExpressionEx -sudo:$sudo "& $editor $arguments" } -} \ No newline at end of file +}