We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent e5b7be9 commit 054ca6cCopy full SHA for 054ca6c
module/PowerShellEditorServices/Commands/Public/CmdletInterface.ps1
@@ -125,7 +125,15 @@ function New-EditorFile {
125
end {
126
# If editorContext is null, then we're in a Temp session and
127
# this cmdlet won't work so return early.
128
- $editorContext = $psEditor.GetEditorContext()
+ try {
129
+ $editorContext = $psEditor.GetEditorContext()
130
+ }
131
+ catch {
132
+ # If there's no editor, this throws an error. Create a new file, and grab the context here.
133
+ # This feels really hacky way to do it, but not sure if there's another way to detect editor context...
134
+ $psEditor.Workspace.NewFile()
135
136
137
if (!$editorContext) {
138
return
139
}
0 commit comments