Move handling generated files to the serialization classes (#8952)

* move handling generated files to the serilization classes

* remove unneeded methods

* fix compile
This commit is contained in:
Anthony Dresser
2020-01-30 21:27:21 -08:00
committed by GitHub
parent 261e6fa89e
commit 7d751a20ab
9 changed files with 27 additions and 58 deletions

View File

@@ -429,8 +429,6 @@ export class EditorGroupView extends Themable implements IEditorGroupView {
return; // nothing to show
}
await this._group.removeNonExitingEditor(); // {{SQL CARBON EDIT}} @udeeshagautam perform async correction for non-existing files
// Determine editor options
let options: EditorOptions;
if (from instanceof EditorGroupView) {

View File

@@ -9,12 +9,9 @@ import { IInstantiationService } from 'vs/platform/instantiation/common/instanti
import { IConfigurationService, IConfigurationChangeEvent } from 'vs/platform/configuration/common/configuration';
import { dispose, Disposable, DisposableStore } from 'vs/base/common/lifecycle';
import { Registry } from 'vs/platform/registry/common/platform';
import { coalesce, firstIndex } from 'vs/base/common/arrays';
import { coalesce } from 'vs/base/common/arrays';
// {{SQL CARBON EDIT}}
import { FileEditorInput } from 'vs/workbench/contrib/files/common/editors/fileEditorInput';
import { QueryEditorInput } from 'sql/workbench/contrib/query/common/queryEditorInput';
import { UntitledTextEditorInput } from 'vs/workbench/common/editor/untitledTextEditorInput';
import { doHandleUpgrade } from 'sql/workbench/common/languageAssociation';
const EditorOpenPositioning = {
@@ -624,14 +621,6 @@ export class EditorGroup extends Disposable {
this.editors.forEach(e => {
const factory = registry.getEditorInputFactory(e.getTypeId());
if (factory) {
// {{SQL CARBON EDIT}}
// don't serialize unmodified unitited files
if (e instanceof UntitledTextEditorInput && !e.isDirty()
&& !this.configurationService.getValue<boolean>('sql.promptToSaveGeneratedFiles')) {
return;
}
// {{SQL CARBON EDIT}} - End
const value = factory.serialize(e);
if (typeof value === 'string') {
serializedEditors.push({ id: e.getTypeId(), value });
@@ -689,26 +678,4 @@ export class EditorGroup extends Disposable {
return this._id;
}
// {{SQL CARBON EDIT}}
async removeNonExitingEditor(): Promise<void> {
let n = 0;
while (n < this.editors.length) {
let editor = this.editors[n];
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));
// remove from MRU list otherwise later if we try to close them it leaves a sticky active editor with no data
this.mru.splice(index, 1);
this.active = this.isActive(editor) ? this.editors[0] : this.active;
editor.dispose();
}
else {
n++;
}
}
}
// {{SQL CARBON EDIT}}
}