mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 18:46:40 -05:00
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:
@@ -30,7 +30,7 @@ import { withNullAsUndefined } from 'vs/base/common/types';
|
||||
import { EditorActivation } from 'vs/platform/editor/common/editor';
|
||||
|
||||
// {{SQL CARBON EDIT}}
|
||||
import { QueryInput } from 'sql/workbench/contrib/query/common/queryInput';
|
||||
import { QueryEditorInput } from 'sql/workbench/contrib/query/common/queryEditorInput';
|
||||
|
||||
export class FileEditorTracker extends Disposable implements IWorkbenchContribution {
|
||||
|
||||
@@ -186,12 +186,12 @@ export class FileEditorTracker extends Disposable implements IWorkbenchContribut
|
||||
}
|
||||
|
||||
// {{SQL CARBON EDIT}} - Support FileEditorInput or QueryInput
|
||||
private getOpenedFileEditors(dirtyState: boolean): (FileEditorInput | QueryInput)[] {
|
||||
const editors: (FileEditorInput | QueryInput)[] = [];
|
||||
private getOpenedFileEditors(dirtyState: boolean): (FileEditorInput | QueryEditorInput)[] {
|
||||
const editors: (FileEditorInput | QueryEditorInput)[] = [];
|
||||
|
||||
this.editorService.editors.forEach(editor => {
|
||||
// {{SQL CARBON EDIT}} - Support FileEditorInput or QueryInput
|
||||
if (editor instanceof FileEditorInput || editor instanceof QueryInput) {
|
||||
if (editor instanceof FileEditorInput || editor instanceof QueryEditorInput) {
|
||||
if (!!editor.isDirty() === dirtyState) {
|
||||
editors.push(editor);
|
||||
}
|
||||
@@ -220,7 +220,7 @@ export class FileEditorTracker extends Disposable implements IWorkbenchContribut
|
||||
this.editorGroupService.groups.forEach(group => {
|
||||
group.editors.forEach(editor => {
|
||||
// {{SQL CARBON EDIT}} - Support FileEditorInput or QueryInput
|
||||
if (editor instanceof FileEditorInput || editor instanceof QueryInput) {
|
||||
if (editor instanceof FileEditorInput || editor instanceof QueryEditorInput) {
|
||||
const resource = editor.getResource();
|
||||
|
||||
// Update Editor if file (or any parent of the input) got renamed or moved
|
||||
|
||||
@@ -46,9 +46,6 @@ import { AsyncDataTree } from 'vs/base/browser/ui/tree/asyncDataTree';
|
||||
import { ExplorerItem, NewExplorerItem } from 'vs/workbench/contrib/files/common/explorerModel';
|
||||
import { onUnexpectedError, getErrorMessage } from 'vs/base/common/errors';
|
||||
|
||||
// {{SQL CARBON EDIT}}
|
||||
import { openNewQuery } from 'sql/workbench/contrib/query/browser/queryActions';
|
||||
|
||||
export const NEW_FILE_COMMAND_ID = 'explorer.newFile';
|
||||
export const NEW_FILE_LABEL = nls.localize('newFile', "New File");
|
||||
|
||||
@@ -155,15 +152,13 @@ export class GlobalNewUntitledFileAction extends Action {
|
||||
constructor(
|
||||
id: string,
|
||||
label: string,
|
||||
// {{SQL CARBON EDIT}} - Make editorService protected and add other services
|
||||
@IEditorService protected readonly editorService: IEditorService,
|
||||
@IInstantiationService private readonly instantiationService: IInstantiationService
|
||||
@IEditorService private readonly editorService: IEditorService
|
||||
) {
|
||||
super(id, label);
|
||||
}
|
||||
|
||||
run(): Promise<any> {
|
||||
return this.instantiationService.invokeFunction(openNewQuery); // {{SQL CARBON EDIT}}
|
||||
return this.editorService.openEditor({ options: { pinned: true } }); // untitled are always pinned
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
import * as nls from 'vs/nls';
|
||||
import { URI } from 'vs/base/common/uri';
|
||||
import { toResource, IEditorCommandsContext, SideBySideEditor, EditorInput } from 'vs/workbench/common/editor'; // {{SQL CARBON EDIT}} add edit input
|
||||
import { toResource, IEditorCommandsContext, SideBySideEditor } from 'vs/workbench/common/editor';
|
||||
import { IWindowOpenable, IOpenWindowOptions, isWorkspaceToOpen, IOpenEmptyWindowOptions } from 'vs/platform/windows/common/windows';
|
||||
import { IHostService } from 'vs/workbench/services/host/browser/host';
|
||||
import { ServicesAccessor, IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
|
||||
@@ -128,14 +128,6 @@ async function save(
|
||||
return doSaveAs(resource, isSaveAs, options, editorService, fileService, untitledEditorService, textFileService, editorGroupService, queryEditorService, environmentService); // {{SQL CARBON EDIT}} add paramater
|
||||
}
|
||||
|
||||
if (resource && (fileService.canHandleResource(resource) || resource.scheme === Schemas.untitled)) {
|
||||
// {{SQL CARBON EDIT}}
|
||||
let editorInput = editorService.activeEditor;
|
||||
if (editorInput instanceof EditorInput && !(<EditorInput>editorInput).savingSupported) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// Save
|
||||
return doSave(resource, options, editorService, textFileService);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user