Skip to content

Commit

Permalink
Merge pull request #609 from tylerl0706/open-editorfile
Browse files Browse the repository at this point in the history
change psedit to Open-EditorFile and alias psedit to it
  • Loading branch information
TylerLeonhardt authored Jan 16, 2018
2 parents dde1aac + e4516c2 commit dafbbc7
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ FunctionsToExport = @('Register-EditorCommand',
'Out-CurrentFile',
'Join-ScriptExtent',
'Test-ScriptExtent',
'psedit')
'Open-EditorFile')

# 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.
CmdletsToExport = @()
Expand All @@ -86,7 +86,7 @@ CmdletsToExport = @()
VariablesToExport = @()

# 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.
AliasesToExport = @()
AliasesToExport = @('psedit')

# DSC resources to export from this module
# DscResourcesToExport = @()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,13 @@ function Unregister-EditorCommand {
}
}

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

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

Export-ModuleMember -Function Open-EditorFile
18 changes: 12 additions & 6 deletions src/PowerShellEditorServices/Session/RemoteFileManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,21 +72,27 @@ public class RemoteFileManager
[string] $PSEditFunction
)
Register-EngineEvent -SourceIdentifier PSESRemoteSessionOpenFile {0}
Register-EngineEvent -SourceIdentifier PSESRemoteSessionOpenFile -Forward
if ((Test-Path -Path 'function:\global:PSEdit') -eq $false)
if ((Test-Path -Path 'function:\global:Open-EditorFile') -eq $false)
{{
Set-Item -Path 'function:\global:PSEdit' -Value $PSEditFunction
Set-Item -Path 'function:\global:Open-EditorFile' -Value $PSEditFunction
Set-Alias psedit Open-EditorFile -Scope Global
}}
";

private const string RemovePSEditFunctionScript = @"
if ((Test-Path -Path 'function:\global:PSEdit') -eq $true)
if (Test-Path -Path 'function:\global:Open-EditorFile')
{
Remove-Item -Path 'function:\global:PSEdit' -Force
Remove-Item -Path 'function:\global:Open-EditorFile' -Force
}
Get-EventSubscriber -SourceIdentifier PSESRemoteSessionOpenFile -EA Ignore | Remove-Event
if (Test-Path -Path 'alias:\psedit')
{
Remove-Item -Path 'alias:\psedit' -Force
}
Get-EventSubscriber -SourceIdentifier PSESRemoteSessionOpenFile -EA Ignore | Unregister-Event
";

private const string SetRemoteContentsScript = @"
Expand Down

0 comments on commit dafbbc7

Please sign in to comment.