From da75681f83297707b1f8bcc8b2626980df3c79ca Mon Sep 17 00:00:00 2001 From: Abbie Petchtes Date: Tue, 2 Jan 2018 13:36:43 -0800 Subject: [PATCH] Fix issue where loading unsave sql file open as untitiledEditorInput (#385) * fix issue where loading unsave sql file open as untitiledEditorInput * add SQL CARBON EDIT comment --- .../parts/editor/editor.contribution.ts | 18 +++++++++++++++--- .../textfile/common/textFileService.ts | 4 +--- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/src/vs/workbench/browser/parts/editor/editor.contribution.ts b/src/vs/workbench/browser/parts/editor/editor.contribution.ts index 24b758468a..05591013b3 100644 --- a/src/vs/workbench/browser/parts/editor/editor.contribution.ts +++ b/src/vs/workbench/browser/parts/editor/editor.contribution.ts @@ -42,6 +42,10 @@ import { ContextKeyExpr } from 'vs/platform/contextkey/common/contextkey'; import { isMacintosh } from 'vs/base/common/platform'; import { GroupOnePicker, GroupTwoPicker, GroupThreePicker, AllEditorsPicker } from 'vs/workbench/browser/parts/editor/editorPicker'; +// {{SQL CARBON EDIT}} +import { QueryResultsInput } from 'sql/parts/query/common/queryResultsInput'; +import { QueryInput } from 'sql/parts/query/common/queryInput'; + // Register String Editor Registry.as(EditorExtensions.Editors).registerEditor( new EditorDescriptor( @@ -132,15 +136,23 @@ class UntitledEditorInputFactory implements IEditorInputFactory { return JSON.stringify(serialized); } - public deserialize(instantiationService: IInstantiationService, serializedEditorInput: string): UntitledEditorInput { - return instantiationService.invokeFunction(accessor => { + // {{SQL CARBON EDIT}} + public deserialize(instantiationService: IInstantiationService, serializedEditorInput: string): EditorInput { + return instantiationService.invokeFunction(accessor => { const deserialized: ISerializedUntitledEditorInput = JSON.parse(serializedEditorInput); const resource = !!deserialized.resourceJSON ? URI.revive(deserialized.resourceJSON) : URI.parse(deserialized.resource); const filePath = resource.scheme === 'file' ? resource.fsPath : void 0; const language = deserialized.modeId; const encoding = deserialized.encoding; - return accessor.get(IWorkbenchEditorService).createInput({ resource, filePath, language, encoding }) as UntitledEditorInput; + // {{SQL CARBON EDIT}} + let input = accessor.get(IWorkbenchEditorService).createInput({ resource, filePath, language, encoding }) as UntitledEditorInput; + if (deserialized.modeId === QueryInput.SCHEMA) { + const queryResultsInput: QueryResultsInput = instantiationService.createInstance(QueryResultsInput, resource.toString()); + return instantiationService.createInstance(QueryInput, input.getName(), '', input, queryResultsInput, undefined); + } else { + return input; + } }); } } diff --git a/src/vs/workbench/services/textfile/common/textFileService.ts b/src/vs/workbench/services/textfile/common/textFileService.ts index 4ebb27f5a5..48c67ed270 100644 --- a/src/vs/workbench/services/textfile/common/textFileService.ts +++ b/src/vs/workbench/services/textfile/common/textFileService.ts @@ -366,9 +366,7 @@ export abstract class TextFileService implements ITextFileService { } // Hot exit - // {{SQL CARBON EDIT}} - // const hotExitMode = configuration && configuration.files ? configuration.files.hotExit : HotExitConfiguration.ON_EXIT; - const hotExitMode = HotExitConfiguration.OFF; + const hotExitMode = configuration && configuration.files ? configuration.files.hotExit : HotExitConfiguration.ON_EXIT; if (hotExitMode === HotExitConfiguration.OFF || hotExitMode === HotExitConfiguration.ON_EXIT_AND_WINDOW_CLOSE) { this.configuredHotExit = hotExitMode; } else {