Rework how we handle custom editors (#5696)

* update how we handle editors

* small edit

* handle changing languages

* implement generic language association

* implement notebook serializers

* fix tests

* formatting

* update how we handle editors

* small edit

* handle changing languages

* implement generic language association

* implement notebook serializers

* fix tests

* formatting

* fix broken

* fix compile

* fix tests

* add back in removed note book contributions

* fix layering

* fix compile errors

* fix workbench

* fix hanging promises

* idk why these changed

* fix change

* add comments to language change code

* fix a few bugs

* add query plan association
This commit is contained in:
Anthony Dresser
2019-11-24 19:22:11 -08:00
committed by GitHub
parent f3a6fc6f88
commit 43387f0d0b
50 changed files with 988 additions and 873 deletions

View File

@@ -447,8 +447,7 @@ export abstract class EditorInput extends Disposable implements IEditorInput {
* Subclasses can set this to false if it does not make sense to split the editor input.
*/
supportsSplitEditor(): boolean {
// {{SQL CARBON EDIT}} @anthonydresser 05/19/2019 investigate
return false; // TODO reenable when multiple Angular components of the same type can be open simultaneously
return true;
}
/**
@@ -475,16 +474,6 @@ export abstract class EditorInput extends Disposable implements IEditorInput {
super.dispose();
}
// {{SQL CARBON EDIT}} @anthonydresser 05/19/2019 investigate
// Saving is not supported in the EditData query editor, so this can be overriden in its Input.
private _savingSupported: boolean = true;
public get savingSupported(): boolean {
return this._savingSupported;
}
public disableSaving() {
this._savingSupported = false;
}
}
export const enum ConfirmResult {

View File

@@ -14,11 +14,9 @@ import { ResourceMap } from 'vs/base/common/map';
import { coalesce, firstIndex } from 'vs/base/common/arrays';
// {{SQL CARBON EDIT}}
import { QueryInput } from 'sql/workbench/contrib/query/common/queryInput';
import { UntitledEditorInput } from 'vs/workbench/common/editor/untitledEditorInput';
import * as CustomInputConverter from 'sql/workbench/browser/customInputConverter';
import { NotebookInput } from 'sql/workbench/contrib/notebook/browser/models/notebookInput';
import { FileEditorInput } from 'vs/workbench/contrib/files/common/editors/fileEditorInput';
import { QueryEditorInput } from 'sql/workbench/contrib/query/common/queryEditorInput';
const EditorOpenPositioning = {
LEFT: 'left',
@@ -643,16 +641,7 @@ export class EditorGroup extends Disposable {
let serializableEditors: EditorInput[] = [];
let serializedEditors: ISerializedEditorInput[] = [];
let serializablePreviewIndex: number | undefined;
// {{SQL CARBON EDIT}}
const editors = this.editors.map(e => {
if (e instanceof QueryInput) {
return e.sql;
} else if (e instanceof NotebookInput) {
return e.textInput;
}
return e;
});
editors.forEach(e => {
this.editors.forEach(e => {
const factory = registry.getEditorInputFactory(e.getTypeId());
if (factory) {
// {{SQL CARBON EDIT}}
@@ -675,16 +664,7 @@ export class EditorGroup extends Disposable {
}
});
// {{SQL CARBON EDIT}}
let mru = this.mru.map(e => {
if (e instanceof QueryInput) {
return e.sql;
} else if (e instanceof NotebookInput) {
return e.textInput;
}
return e;
});
const serializableMru = mru.map(e => this.indexOf(e, serializableEditors)).filter(i => i >= 0);
const serializableMru = this.mru.map(e => this.indexOf(e, serializableEditors)).filter(i => i >= 0);
return {
id: this.id,
@@ -714,8 +694,7 @@ export class EditorGroup extends Disposable {
this.updateResourceMap(editor, false /* add */);
}
// {{SQL CARBON EDIT}}
return CustomInputConverter.convertEditorInput(editor, undefined, this.instantiationService);
return editor;
}
return null;
@@ -737,7 +716,7 @@ export class EditorGroup extends Disposable {
let n = 0;
while (n < this.editors.length) {
let editor = this.editors[n];
if (editor instanceof QueryInput && editor.matchInputInstanceType(FileEditorInput) && !editor.isDirty() && await editor.inputFileExists() === false && this.editors.length > 1) {
if (editor instanceof QueryEditorInput && editor.matchInputInstanceType(FileEditorInput) && !editor.isDirty() && await editor.inputFileExists() === false && this.editors.length > 1) {
// remove from editors list so that they do not get restored
this.editors.splice(n, 1);
let index = firstIndex(this.mru, e => e.matches(editor));

View File

@@ -125,11 +125,6 @@ export class UntitledEditorInput extends EditorInput implements IEncodingSupport
}
isDirty(): boolean {
// {{SQL CARBON EDIT}}
if (!this.savingSupported) {
return false;
}
if (this.cachedModel) {
return this.cachedModel.isDirty();
}