Skip to content

Commit adba47d

Browse files
committed
Fix New-EditorFile inserting text in wrong editor
The object returned from GetEditorContext() always points to the original file in CurrentFile. We need to get an updated object after opening or creating a file to insert text in the right editor. Fix PowerShell/vscode-powershell#3192
1 parent ca227b5 commit adba47d

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
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
}

0 commit comments

Comments
 (0)