Avoid extra call to reveal if the editor is already active

This commit is contained in:
Matt Bierner 2021-04-20 16:14:49 -07:00
parent 9b8d52ded3
commit 1d54cdf54a
No known key found for this signature in database
GPG key ID: 099C331567E11888

View file

@ -243,9 +243,13 @@ export class WebviewEditorService extends Disposable implements IWebviewWorkbenc
group: IEditorGroup,
preserveFocus: boolean
): void {
const editor = this.findTopLevelEditorForWebview(webview);
const topLevelEditor = this.findTopLevelEditorForWebview(webview);
if (webview.group === group.id) {
this._editorService.openEditor(editor, {
if (this._editorService.activeEditor === topLevelEditor) {
return;
}
this._editorService.openEditor(topLevelEditor, {
preserveFocus,
// preserve pre 1.38 behaviour to not make group active when preserveFocus: true
// but make sure to restore the editor to fix https://github.com/microsoft/vscode/issues/79633
@ -254,7 +258,7 @@ export class WebviewEditorService extends Disposable implements IWebviewWorkbenc
} else {
const groupView = this._editorGroupService.getGroup(webview.group!);
if (groupView) {
groupView.moveEditor(editor, group, { preserveFocus });
groupView.moveEditor(topLevelEditor, group, { preserveFocus });
}
}
}