Skip to content

Commit dafbbc7

Browse files
Merge pull request #609 from tylerl0706/open-editorfile
change psedit to Open-EditorFile and alias psedit to it
2 parents dde1aac + e4516c2 commit dafbbc7

File tree

3 files changed

+19
-11
lines changed

3 files changed

+19
-11
lines changed

module/PowerShellEditorServices/Commands/PowerShellEditorServices.Commands.psd1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ FunctionsToExport = @('Register-EditorCommand',
7777
'Out-CurrentFile',
7878
'Join-ScriptExtent',
7979
'Test-ScriptExtent',
80-
'psedit')
80+
'Open-EditorFile')
8181

8282
# Cmdlets to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no cmdlets to export.
8383
CmdletsToExport = @()
@@ -86,7 +86,7 @@ CmdletsToExport = @()
8686
VariablesToExport = @()
8787

8888
# Aliases to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no aliases to export.
89-
AliasesToExport = @()
89+
AliasesToExport = @('psedit')
9090

9191
# DSC resources to export from this module
9292
# DscResourcesToExport = @()

module/PowerShellEditorServices/Commands/Public/CmdletInterface.ps1

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,11 +77,13 @@ function Unregister-EditorCommand {
7777
}
7878
}
7979

80-
function psedit {
80+
function Open-EditorFile {
8181
param([Parameter(Mandatory=$true)]$FilePaths)
8282

83-
dir $FilePaths | where { !$_.PSIsContainer } | % {
83+
Get-ChildItem $FilePaths -File | ForEach-Object {
8484
$psEditor.Workspace.OpenFile($_.FullName)
8585
}
8686
}
87-
Export-ModuleMember -Function psedit
87+
Set-Alias psedit Open-EditorFile -Scope Global
88+
89+
Export-ModuleMember -Function Open-EditorFile

src/PowerShellEditorServices/Session/RemoteFileManager.cs

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -72,21 +72,27 @@ public class RemoteFileManager
7272
[string] $PSEditFunction
7373
)
7474
75-
Register-EngineEvent -SourceIdentifier PSESRemoteSessionOpenFile {0}
75+
Register-EngineEvent -SourceIdentifier PSESRemoteSessionOpenFile -Forward
7676
77-
if ((Test-Path -Path 'function:\global:PSEdit') -eq $false)
77+
if ((Test-Path -Path 'function:\global:Open-EditorFile') -eq $false)
7878
{{
79-
Set-Item -Path 'function:\global:PSEdit' -Value $PSEditFunction
79+
Set-Item -Path 'function:\global:Open-EditorFile' -Value $PSEditFunction
80+
Set-Alias psedit Open-EditorFile -Scope Global
8081
}}
8182
";
8283

8384
private const string RemovePSEditFunctionScript = @"
84-
if ((Test-Path -Path 'function:\global:PSEdit') -eq $true)
85+
if (Test-Path -Path 'function:\global:Open-EditorFile')
8586
{
86-
Remove-Item -Path 'function:\global:PSEdit' -Force
87+
Remove-Item -Path 'function:\global:Open-EditorFile' -Force
8788
}
8889
89-
Get-EventSubscriber -SourceIdentifier PSESRemoteSessionOpenFile -EA Ignore | Remove-Event
90+
if (Test-Path -Path 'alias:\psedit')
91+
{
92+
Remove-Item -Path 'alias:\psedit' -Force
93+
}
94+
95+
Get-EventSubscriber -SourceIdentifier PSESRemoteSessionOpenFile -EA Ignore | Unregister-Event
9096
";
9197

9298
private const string SetRemoteContentsScript = @"

0 commit comments

Comments
 (0)