Fix duplicate editor windows on reload (#16893)

This commit is contained in:
Charles Gagnon
2021-08-25 20:07:58 -07:00
committed by GitHub
parent f66a0f9761
commit 0aede16aaa
3 changed files with 7 additions and 2 deletions

View File

@@ -29,6 +29,8 @@ export const SearchViewFocusedKey = new RawContextKey<boolean>('notebookSearchVi
export const InputBoxFocusedKey = new RawContextKey<boolean>('inputBoxFocus', false);
export const SearchInputBoxFocusedKey = new RawContextKey<boolean>('searchInputBoxFocus', false);
export const UNTITLED_NOTEBOOK_TYPEID = 'workbench.editorinputs.untitledNotebookInput';
export const enum NotebookLanguage {
Notebook = 'Notebook',
Ipynb = 'ipynb'

View File

@@ -11,9 +11,10 @@ import { NotebookInput } from 'sql/workbench/contrib/notebook/browser/models/not
import { INotebookService } from 'sql/workbench/services/notebook/browser/notebookService';
import { UntitledTextEditorInput } from 'vs/workbench/services/untitled/common/untitledTextEditorInput';
import { EditorInputCapabilities } from 'vs/workbench/common/editor';
import { UNTITLED_NOTEBOOK_TYPEID } from 'sql/workbench/common/constants';
export class UntitledNotebookInput extends NotebookInput {
public static ID: string = 'workbench.editorinputs.untitledNotebookInput';
public static ID: string = UNTITLED_NOTEBOOK_TYPEID;
constructor(
title: string,

View File

@@ -19,6 +19,8 @@ import { UntitledTextEditorInput } from 'vs/workbench/services/untitled/common/u
import { IWorkbenchContribution } from 'vs/workbench/common/contributions';
import { NO_TYPE_ID } from 'vs/workbench/services/workingCopy/common/workingCopy';
import { IWorkingCopyEditorService } from 'vs/workbench/services/workingCopy/common/workingCopyEditorService';
import { UntitledQueryEditorInput } from 'sql/workbench/common/editor/query/untitledQueryEditorInput'; // {{SQL CARBON EDIT}} Handle our untitled inputs as well
import { UNTITLED_NOTEBOOK_TYPEID } from 'sql/workbench/common/constants'; // {{SQL CARBON EDIT}} Handle our untitled inputs as well
interface ISerializedUntitledTextEditorInput {
resourceJSON: UriComponents;
@@ -101,7 +103,7 @@ export class UntitledTextEditorWorkingCopyEditorHandler extends Disposable imple
private installHandler(): void {
this._register(this.workingCopyEditorService.registerHandler({
handles: workingCopy => workingCopy.resource.scheme === Schemas.untitled && workingCopy.typeId === NO_TYPE_ID,
isOpen: (workingCopy, editor) => editor instanceof UntitledTextEditorInput && isEqual(workingCopy.resource, editor.resource),
isOpen: (workingCopy, editor) => (editor instanceof UntitledTextEditorInput || editor instanceof UntitledQueryEditorInput || editor.typeId === UNTITLED_NOTEBOOK_TYPEID) && isEqual(workingCopy.resource, editor.resource), // {{SQL CARBON EDIT}} Handle our untitled inputs as well. Notebook input can't be imported due to layering currently so just use the typeID for that
createEditor: workingCopy => {
let editorInputResource: URI;