-
Notifications
You must be signed in to change notification settings - Fork 235
change psedit to Open-EditorFile and alias psedit to it #609
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -77,7 +77,8 @@ FunctionsToExport = @('Register-EditorCommand', | |
'Out-CurrentFile', | ||
'Join-ScriptExtent', | ||
'Test-ScriptExtent', | ||
'psedit') | ||
'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 = @() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should there be an entry to export There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh interesting! didn't know you needed to list aliases in FunctionsToExport. Thanks! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed! |
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -74,16 +74,22 @@ public class RemoteFileManager | |
|
||
Register-EngineEvent -SourceIdentifier PSESRemoteSessionOpenFile {0} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sorry to pollute your PR, but I found another one. The input for Register-EngineEvent -SourceIdentifier PSESRemoteSessionOpenFile
# Register-EngineEvent : Action must be specified for non-forwarded events.
# At line:1 char:1
# + Register-EngineEvent -SourceIdentifier PSESRemoteSessionOpenFile
# + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# + CategoryInfo : InvalidArgument: (:) [Register-EngineEvent], ArgumentException
# + FullyQualifiedErrorId : ACTION_MANDATORY_FOR_LOCAL,Microsoft.PowerShell.Commands.RegisterEngineEventCommand I'm thinking we probably just need to always pass There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
which session types? I haven't had any issue with WinRM, SSH, or PowerShell Direct There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That said, I can change:
to
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @tylerl0706 ah right, the condition is probably never hit. It should still be changed at some point, but I doubt it actually affects anything. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
|
||
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 | ||
} | ||
|
||
if (Test-Path -Path 'alias:\psedit') | ||
{ | ||
Remove-Item -Path 'alias:\psedit' -Force | ||
} | ||
|
||
Get-EventSubscriber -SourceIdentifier PSESRemoteSessionOpenFile -EA Ignore | Remove-Event | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This PR may not be the right place to change this, but are we sure There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Honestly I'm not sure, I stole this code from the ISE codebase :) If you think there's an actual problem here we should definitely fix it There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yep Register-EngineEvent -SourceIdentifier PSESRemoteSessionOpenFile -Forward
Get-EventSubscriber -SourceIdentifier PSESRemoteSessionOpenFile | Remove-Event
# Remove-Event : The input object cannot be bound to any parameters for the command either because the command does not
# take pipeline input or the input and its properties do not match any of the parameters that take pipeline input.
# At line:1 char:65
# + ... ntSubscriber -SourceIdentifier PSESRemoteSessionOpenFile | Remove-Event
# + ~~~~~~~~~~~~
# + CategoryInfo : InvalidArgument: (System.Manageme...EventSubscriber:PSObject) [Remove-Event], ParameterB
# indingException
# + FullyQualifiedErrorId : InputObjectNotBound,Microsoft.PowerShell.Commands.RemoveEventCommand @tylerl0706 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You are right :)
I'll change it to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done :) |
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is an
AliasesToExport
field down below to putpsedit
in. That is where it should go.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Doh! Fixed now.