mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 18:46:40 -05:00
* #4363: Reopen notebook editors when ADS launched * Code review changes
This commit is contained in:
@@ -14,7 +14,7 @@ import { QueryInput } from 'sql/parts/query/common/queryInput';
|
|||||||
import { IQueryEditorOptions } from 'sql/workbench/services/queryEditor/common/queryEditorService';
|
import { IQueryEditorOptions } from 'sql/workbench/services/queryEditor/common/queryEditorService';
|
||||||
import { QueryPlanInput } from 'sql/parts/queryPlan/queryPlanInput';
|
import { QueryPlanInput } from 'sql/parts/queryPlan/queryPlanInput';
|
||||||
import { NotebookInput } from 'sql/parts/notebook/notebookInput';
|
import { NotebookInput } from 'sql/parts/notebook/notebookInput';
|
||||||
import { DEFAULT_NOTEBOOK_PROVIDER, INotebookService } from 'sql/workbench/services/notebook/common/notebookService';
|
import { INotebookService } from 'sql/workbench/services/notebook/common/notebookService';
|
||||||
import { ResourceEditorInput } from 'vs/workbench/common/editor/resourceEditorInput';
|
import { ResourceEditorInput } from 'vs/workbench/common/editor/resourceEditorInput';
|
||||||
import { notebookModeId } from 'sql/common/constants';
|
import { notebookModeId } from 'sql/common/constants';
|
||||||
|
|
||||||
@@ -57,14 +57,12 @@ export function convertEditorInput(input: EditorInput, options: IQueryEditorOpti
|
|||||||
//Notebook
|
//Notebook
|
||||||
uri = getNotebookEditorUri(input, instantiationService);
|
uri = getNotebookEditorUri(input, instantiationService);
|
||||||
if (uri) {
|
if (uri) {
|
||||||
return withService<INotebookService, NotebookInput>(instantiationService, INotebookService, notebookService => {
|
let fileName: string = 'untitled';
|
||||||
let fileName: string = 'untitled';
|
if (input) {
|
||||||
if (input) {
|
fileName = input.getName();
|
||||||
fileName = input.getName();
|
}
|
||||||
}
|
let notebookInput: NotebookInput = instantiationService.createInstance(NotebookInput, fileName, uri, input);
|
||||||
let notebookInput: NotebookInput = instantiationService.createInstance(NotebookInput, fileName, uri);
|
return notebookInput;
|
||||||
return notebookInput;
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return input;
|
return input;
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ import { notebookModeId } from 'sql/common/constants';
|
|||||||
import { ITextFileService, ISaveOptions } from 'vs/workbench/services/textfile/common/textfiles';
|
import { ITextFileService, ISaveOptions } from 'vs/workbench/services/textfile/common/textfiles';
|
||||||
import { LocalContentManager } from 'sql/workbench/services/notebook/node/localContentManager';
|
import { LocalContentManager } from 'sql/workbench/services/notebook/node/localContentManager';
|
||||||
import { IConnectionProfile } from 'sql/platform/connection/common/interfaces';
|
import { IConnectionProfile } from 'sql/platform/connection/common/interfaces';
|
||||||
|
import { UntitledEditorInput } from 'vs/workbench/common/editor/untitledEditorInput';
|
||||||
|
|
||||||
export type ModeViewSaveHandler = (handle: number) => Thenable<boolean>;
|
export type ModeViewSaveHandler = (handle: number) => Thenable<boolean>;
|
||||||
|
|
||||||
@@ -142,6 +143,7 @@ export class NotebookInput extends EditorInput {
|
|||||||
|
|
||||||
constructor(private _title: string,
|
constructor(private _title: string,
|
||||||
private resource: URI,
|
private resource: URI,
|
||||||
|
private _textInput: UntitledEditorInput,
|
||||||
@ITextModelService private textModelService: ITextModelService,
|
@ITextModelService private textModelService: ITextModelService,
|
||||||
@IUntitledEditorService untitledEditorService: IUntitledEditorService,
|
@IUntitledEditorService untitledEditorService: IUntitledEditorService,
|
||||||
@IInstantiationService private instantiationService: IInstantiationService,
|
@IInstantiationService private instantiationService: IInstantiationService,
|
||||||
@@ -154,6 +156,10 @@ export class NotebookInput extends EditorInput {
|
|||||||
this.assignProviders();
|
this.assignProviders();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public get textInput(): UntitledEditorInput {
|
||||||
|
return this._textInput;
|
||||||
|
}
|
||||||
|
|
||||||
public confirmSave(): TPromise<ConfirmResult> {
|
public confirmSave(): TPromise<ConfirmResult> {
|
||||||
return this._model.confirmSave();
|
return this._model.confirmSave();
|
||||||
}
|
}
|
||||||
@@ -258,7 +264,7 @@ export class NotebookInput extends EditorInput {
|
|||||||
} else {
|
} else {
|
||||||
let textOrUntitledEditorModel: UntitledEditorModel | IEditorModel;
|
let textOrUntitledEditorModel: UntitledEditorModel | IEditorModel;
|
||||||
if (this.resource.scheme === Schemas.untitled) {
|
if (this.resource.scheme === Schemas.untitled) {
|
||||||
textOrUntitledEditorModel = await this._untitledEditorService.loadOrCreate({ resource: this.resource, modeId: notebookModeId });
|
textOrUntitledEditorModel = await this._textInput.resolve();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
const textEditorModelReference = await this.textModelService.createModelReference(this.resource);
|
const textEditorModelReference = await this.textModelService.createModelReference(this.resource);
|
||||||
|
|||||||
@@ -30,6 +30,9 @@ import { disposed } from 'vs/base/common/errors';
|
|||||||
import { ICellModel, NotebookContentChange, INotebookModel } from 'sql/parts/notebook/models/modelInterfaces';
|
import { ICellModel, NotebookContentChange, INotebookModel } from 'sql/parts/notebook/models/modelInterfaces';
|
||||||
import { NotebookChangeType, CellTypes } from 'sql/parts/notebook/models/contracts';
|
import { NotebookChangeType, CellTypes } from 'sql/parts/notebook/models/contracts';
|
||||||
import { ICapabilitiesService } from 'sql/platform/capabilities/common/capabilitiesService';
|
import { ICapabilitiesService } from 'sql/platform/capabilities/common/capabilitiesService';
|
||||||
|
import { IUntitledEditorService } from 'vs/workbench/services/untitled/common/untitledEditorService';
|
||||||
|
import { notebookModeId } from 'sql/common/constants';
|
||||||
|
import { UntitledEditorInput } from 'vs/workbench/common/editor/untitledEditorInput';
|
||||||
|
|
||||||
class MainThreadNotebookEditor extends Disposable {
|
class MainThreadNotebookEditor extends Disposable {
|
||||||
private _contentChangedEmitter = new Emitter<NotebookContentChange>();
|
private _contentChangedEmitter = new Emitter<NotebookContentChange>();
|
||||||
@@ -290,6 +293,7 @@ export class MainThreadNotebookDocumentsAndEditors extends Disposable implements
|
|||||||
private _modelToDisposeMap = new Map<string, IDisposable>();
|
private _modelToDisposeMap = new Map<string, IDisposable>();
|
||||||
constructor(
|
constructor(
|
||||||
extHostContext: IExtHostContext,
|
extHostContext: IExtHostContext,
|
||||||
|
@IUntitledEditorService private _untitledEditorService: IUntitledEditorService,
|
||||||
@IInstantiationService private _instantiationService: IInstantiationService,
|
@IInstantiationService private _instantiationService: IInstantiationService,
|
||||||
@IEditorService private _editorService: IEditorService,
|
@IEditorService private _editorService: IEditorService,
|
||||||
@IEditorGroupsService private _editorGroupService: IEditorGroupsService,
|
@IEditorGroupsService private _editorGroupService: IEditorGroupsService,
|
||||||
@@ -361,9 +365,11 @@ export class MainThreadNotebookDocumentsAndEditors extends Disposable implements
|
|||||||
preserveFocus: options.preserveFocus,
|
preserveFocus: options.preserveFocus,
|
||||||
pinned: !options.preview
|
pinned: !options.preview
|
||||||
};
|
};
|
||||||
let trusted = uri.scheme === Schemas.untitled;
|
let isUntitled: boolean = uri.scheme === Schemas.untitled;
|
||||||
let input = this._instantiationService.createInstance(NotebookInput, uri.fsPath, uri);
|
|
||||||
input.isTrusted = trusted;
|
const fileInput: UntitledEditorInput = isUntitled ? this._untitledEditorService.createOrGet(uri, notebookModeId) : undefined;
|
||||||
|
let input = this._instantiationService.createInstance(NotebookInput, uri.fsPath, uri, fileInput);
|
||||||
|
input.isTrusted = isUntitled;
|
||||||
input.defaultKernel = options.defaultKernel;
|
input.defaultKernel = options.defaultKernel;
|
||||||
input.connectionProfile = new ConnectionProfile(this._capabilitiesService, options.connectionProfile);
|
input.connectionProfile = new ConnectionProfile(this._capabilitiesService, options.connectionProfile);
|
||||||
|
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ import { ResourceMap } from 'vs/base/common/map';
|
|||||||
import { QueryInput } from 'sql/parts/query/common/queryInput';
|
import { QueryInput } from 'sql/parts/query/common/queryInput';
|
||||||
import { UntitledEditorInput } from 'vs/workbench/common/editor/untitledEditorInput';
|
import { UntitledEditorInput } from 'vs/workbench/common/editor/untitledEditorInput';
|
||||||
import * as CustomInputConverter from 'sql/parts/common/customInputConverter';
|
import * as CustomInputConverter from 'sql/parts/common/customInputConverter';
|
||||||
|
import { NotebookInput } from 'sql/parts/notebook/notebookInput';
|
||||||
|
|
||||||
const EditorOpenPositioning = {
|
const EditorOpenPositioning = {
|
||||||
LEFT: 'left',
|
LEFT: 'left',
|
||||||
@@ -624,6 +625,8 @@ export class EditorGroup extends Disposable {
|
|||||||
let editors = this.editors.map(e => {
|
let editors = this.editors.map(e => {
|
||||||
if (e instanceof QueryInput) {
|
if (e instanceof QueryInput) {
|
||||||
return e.sql;
|
return e.sql;
|
||||||
|
} else if (e instanceof NotebookInput) {
|
||||||
|
return e.textInput;
|
||||||
}
|
}
|
||||||
return e;
|
return e;
|
||||||
});
|
});
|
||||||
@@ -654,6 +657,8 @@ export class EditorGroup extends Disposable {
|
|||||||
let mru = this.mru.map(e => {
|
let mru = this.mru.map(e => {
|
||||||
if (e instanceof QueryInput) {
|
if (e instanceof QueryInput) {
|
||||||
return e.sql;
|
return e.sql;
|
||||||
|
} else if (e instanceof NotebookInput) {
|
||||||
|
return e.textInput;
|
||||||
}
|
}
|
||||||
return e;
|
return e;
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -528,10 +528,10 @@ export class EditorService extends Disposable implements EditorServiceImpl {
|
|||||||
if (!untitledInput.resource || typeof untitledInput.filePath === 'string' || (untitledInput.resource instanceof URI && untitledInput.resource.scheme === Schemas.untitled)) {
|
if (!untitledInput.resource || typeof untitledInput.filePath === 'string' || (untitledInput.resource instanceof URI && untitledInput.resource.scheme === Schemas.untitled)) {
|
||||||
// {{SQL CARBON EDIT}}
|
// {{SQL CARBON EDIT}}
|
||||||
|
|
||||||
let mode: string = getFileMode( this.instantiationService, untitledInput.resource);
|
let modeId: string = untitledInput.language ? untitledInput.language : getFileMode( this.instantiationService, untitledInput.resource);
|
||||||
return convertEditorInput(this.untitledEditorService.createOrGet(
|
return convertEditorInput(this.untitledEditorService.createOrGet(
|
||||||
untitledInput.filePath ? URI.file(untitledInput.filePath) : untitledInput.resource,
|
untitledInput.filePath ? URI.file(untitledInput.filePath) : untitledInput.resource,
|
||||||
mode,
|
modeId,
|
||||||
untitledInput.contents,
|
untitledInput.contents,
|
||||||
untitledInput.encoding
|
untitledInput.encoding
|
||||||
), undefined, this.instantiationService);
|
), undefined, this.instantiationService);
|
||||||
|
|||||||
Reference in New Issue
Block a user