Skip to content

Commit 7d6b961

Browse files
Merge pull request #1997 from fflaten/module-patch1
Fix New-EditorFile adding content in current file
2 parents ca227b5 + 8e4d140 commit 7d6b961

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

module/PowerShellEditorServices/Commands/Public/CmdletInterface.ps1

+2-2
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ function New-EditorFile {
155155
}
156156

157157
$psEditor.Workspace.OpenFile($fileName, $preview)
158-
$editorContext.CurrentFile.InsertText(($valueList | Out-String))
158+
$psEditor.GetEditorContext().CurrentFile.InsertText(($valueList | Out-String))
159159
} else {
160160
$PSCmdlet.WriteError( (
161161
New-Object -TypeName System.Management.Automation.ErrorRecord -ArgumentList @(
@@ -167,7 +167,7 @@ function New-EditorFile {
167167
}
168168
} else {
169169
$psEditor.Workspace.NewFile()
170-
$editorContext.CurrentFile.InsertText(($valueList | Out-String))
170+
$psEditor.GetEditorContext().CurrentFile.InsertText(($valueList | Out-String))
171171
}
172172
}
173173
}

module/PowerShellEditorServices/Commands/Public/Out-CurrentFile.ps1

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ function Out-CurrentFile {
2626

2727
try {
2828
# If there is no file open
29-
$psEditor.GetEditorContext()
29+
$null = $psEditor.GetEditorContext()
3030
}
3131
catch {
3232
# create a new one

0 commit comments

Comments
 (0)