mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-01-29 09:35:38 -05:00
Merge from vscode 1fbacccbc900bb59ba8a8f26a4128d48a1c97842
This commit is contained in:
@@ -16,7 +16,7 @@ import { ITextModelService } from 'vs/editor/common/services/resolverService';
|
||||
import { INotebookModel, IContentManager, NotebookContentChange } from 'sql/workbench/contrib/notebook/browser/models/modelInterfaces';
|
||||
import { TextFileEditorModel } from 'vs/workbench/services/textfile/common/textFileEditorModel';
|
||||
import { Schemas } from 'vs/base/common/network';
|
||||
import { ITextFileSaveOptions } from 'vs/workbench/services/textfile/common/textfiles';
|
||||
import { ITextFileSaveOptions, ITextFileEditorModel } from 'vs/workbench/services/textfile/common/textfiles';
|
||||
import { LocalContentManager } from 'sql/workbench/services/notebook/common/localContentManager';
|
||||
import { IConnectionProfile } from 'sql/platform/connection/common/interfaces';
|
||||
import { IExtensionService } from 'vs/workbench/services/extensions/common/extensions';
|
||||
@@ -26,7 +26,7 @@ import { Deferred } from 'sql/base/common/promise';
|
||||
import { NotebookTextFileModel } from 'sql/workbench/contrib/notebook/browser/models/notebookTextFileModel';
|
||||
import { ITextResourcePropertiesService } from 'vs/editor/common/services/textResourceConfigurationService';
|
||||
import { ResourceEditorModel } from 'vs/workbench/common/editor/resourceEditorModel';
|
||||
import { UntitledTextEditorModel } from 'vs/workbench/services/untitled/common/untitledTextEditorModel';
|
||||
import { UntitledTextEditorModel, IUntitledTextEditorModel } from 'vs/workbench/services/untitled/common/untitledTextEditorModel';
|
||||
import { UntitledTextEditorInput } from 'vs/workbench/services/untitled/common/untitledTextEditorInput';
|
||||
import { ResourceEditorInput } from 'vs/workbench/common/editor/resourceEditorInput';
|
||||
import { FileEditorInput } from 'vs/workbench/contrib/files/common/editors/fileEditorInput';
|
||||
@@ -42,7 +42,7 @@ export class NotebookEditorModel extends EditorModel {
|
||||
private readonly _onDidChangeDirty: Emitter<void> = this._register(new Emitter<void>());
|
||||
private _lastEditFullReplacement: boolean;
|
||||
constructor(public readonly notebookUri: URI,
|
||||
private textEditorModel: TextFileEditorModel | UntitledTextEditorModel | ResourceEditorModel,
|
||||
private textEditorModel: ITextFileEditorModel | IUntitledTextEditorModel | ResourceEditorModel,
|
||||
@INotebookService private notebookService: INotebookService,
|
||||
@ITextResourcePropertiesService private textResourcePropertiesService: ITextResourcePropertiesService
|
||||
) {
|
||||
@@ -198,7 +198,7 @@ export abstract class NotebookInput extends EditorInput {
|
||||
private _parentContainer: HTMLElement;
|
||||
private readonly _layoutChanged: Emitter<void> = this._register(new Emitter<void>());
|
||||
private _model: NotebookEditorModel;
|
||||
private _untitledEditorModel: UntitledTextEditorModel;
|
||||
private _untitledEditorModel: IUntitledTextEditorModel;
|
||||
private _contentManager: IContentManager;
|
||||
private _providersLoaded: Promise<void>;
|
||||
private _dirtyListener: IDisposable;
|
||||
@@ -328,11 +328,11 @@ export abstract class NotebookInput extends EditorInput {
|
||||
return this.resource;
|
||||
}
|
||||
|
||||
public get untitledEditorModel(): UntitledTextEditorModel {
|
||||
public get untitledEditorModel(): IUntitledTextEditorModel {
|
||||
return this._untitledEditorModel;
|
||||
}
|
||||
|
||||
public set untitledEditorModel(value: UntitledTextEditorModel) {
|
||||
public set untitledEditorModel(value: IUntitledTextEditorModel) {
|
||||
this._untitledEditorModel = value;
|
||||
}
|
||||
|
||||
@@ -346,7 +346,7 @@ export abstract class NotebookInput extends EditorInput {
|
||||
if (this._model) {
|
||||
return Promise.resolve(this._model);
|
||||
} else {
|
||||
let textOrUntitledEditorModel: TextFileEditorModel | UntitledTextEditorModel | ResourceEditorModel;
|
||||
let textOrUntitledEditorModel: ITextFileEditorModel | IUntitledTextEditorModel | ResourceEditorModel;
|
||||
if (this.resource.scheme === Schemas.untitled) {
|
||||
if (this._untitledEditorModel) {
|
||||
this._untitledEditorModel.textEditorModel.onBeforeAttached();
|
||||
|
||||
@@ -7,8 +7,8 @@ import { Range, IRange } from 'vs/editor/common/core/range';
|
||||
import { FindMatch } from 'vs/editor/common/model';
|
||||
import { NotebookContentChange, INotebookModel } from 'sql/workbench/contrib/notebook/browser/models/modelInterfaces';
|
||||
import { NotebookChangeType } from 'sql/workbench/services/notebook/common/contracts';
|
||||
import { BaseTextEditorModel } from 'vs/workbench/common/editor/textEditorModel';
|
||||
import { repeat } from 'vs/base/common/strings';
|
||||
import { ITextEditorModel } from 'vs/workbench/common/editor';
|
||||
|
||||
export class NotebookTextFileModel {
|
||||
// save active cell's line/column in editor model for the beginning of the source property
|
||||
@@ -33,7 +33,7 @@ export class NotebookTextFileModel {
|
||||
}
|
||||
}
|
||||
|
||||
public transformAndApplyEditForSourceUpdate(contentChange: NotebookContentChange, textEditorModel: BaseTextEditorModel): boolean {
|
||||
public transformAndApplyEditForSourceUpdate(contentChange: NotebookContentChange, textEditorModel: ITextEditorModel): boolean {
|
||||
let cellGuidRange = this.getCellNodeByGuid(textEditorModel, contentChange.cells[0].cellGuid);
|
||||
|
||||
// convert the range to leverage offsets in the json
|
||||
@@ -109,7 +109,7 @@ export class NotebookTextFileModel {
|
||||
return false;
|
||||
}
|
||||
|
||||
public transformAndApplyEditForOutputUpdate(contentChange: NotebookContentChange, textEditorModel: BaseTextEditorModel): boolean {
|
||||
public transformAndApplyEditForOutputUpdate(contentChange: NotebookContentChange, textEditorModel: ITextEditorModel): boolean {
|
||||
if (Array.isArray(contentChange.cells[0].outputs) && contentChange.cells[0].outputs.length > 0) {
|
||||
let newOutput = JSON.stringify(contentChange.cells[0].outputs[contentChange.cells[0].outputs.length - 1], undefined, ' ');
|
||||
if (contentChange.cells[0].outputs.length > 1) {
|
||||
@@ -136,7 +136,7 @@ export class NotebookTextFileModel {
|
||||
return false;
|
||||
}
|
||||
|
||||
public transformAndApplyEditForCellUpdated(contentChange: NotebookContentChange, textEditorModel: BaseTextEditorModel): boolean {
|
||||
public transformAndApplyEditForCellUpdated(contentChange: NotebookContentChange, textEditorModel: ITextEditorModel): boolean {
|
||||
let executionCountMatch = this.getExecutionCountRange(textEditorModel, contentChange.cells[0].cellGuid);
|
||||
if (executionCountMatch && executionCountMatch.range) {
|
||||
// Execution count can be between 0 and n characters long
|
||||
@@ -161,7 +161,7 @@ export class NotebookTextFileModel {
|
||||
return true;
|
||||
}
|
||||
|
||||
public transformAndApplyEditForClearOutput(contentChange: NotebookContentChange, textEditorModel: BaseTextEditorModel): boolean {
|
||||
public transformAndApplyEditForClearOutput(contentChange: NotebookContentChange, textEditorModel: ITextEditorModel): boolean {
|
||||
if (!textEditorModel || !contentChange || !contentChange.cells || !contentChange.cells[0] || !contentChange.cells[0].cellGuid) {
|
||||
return false;
|
||||
}
|
||||
@@ -178,7 +178,7 @@ export class NotebookTextFileModel {
|
||||
return false;
|
||||
}
|
||||
|
||||
public replaceEntireTextEditorModel(notebookModel: INotebookModel, type: NotebookChangeType, textEditorModel: BaseTextEditorModel) {
|
||||
public replaceEntireTextEditorModel(notebookModel: INotebookModel, type: NotebookChangeType, textEditorModel: ITextEditorModel) {
|
||||
let content = JSON.stringify(notebookModel.toJSON(type), undefined, ' ');
|
||||
let model = textEditorModel.textEditorModel;
|
||||
let endLine = model.getLineCount();
|
||||
@@ -190,7 +190,7 @@ export class NotebookTextFileModel {
|
||||
}
|
||||
|
||||
// Find the beginning of a cell's source in the text editor model
|
||||
private updateSourceBeginRange(textEditorModel: BaseTextEditorModel, cellGuid: string): void {
|
||||
private updateSourceBeginRange(textEditorModel: ITextEditorModel, cellGuid: string): void {
|
||||
if (!cellGuid) {
|
||||
return;
|
||||
}
|
||||
@@ -210,7 +210,7 @@ export class NotebookTextFileModel {
|
||||
}
|
||||
|
||||
// Find the beginning of a cell's outputs in the text editor model
|
||||
private updateOutputBeginRange(textEditorModel: BaseTextEditorModel, cellGuid: string): void {
|
||||
private updateOutputBeginRange(textEditorModel: ITextEditorModel, cellGuid: string): void {
|
||||
if (!cellGuid) {
|
||||
return undefined;
|
||||
}
|
||||
@@ -230,7 +230,7 @@ export class NotebookTextFileModel {
|
||||
|
||||
// Find the end of a cell's outputs in the text editor model
|
||||
// This will be used as a starting point for any future outputs
|
||||
private getEndOfOutputs(textEditorModel: BaseTextEditorModel, cellGuid: string) {
|
||||
private getEndOfOutputs(textEditorModel: ITextEditorModel, cellGuid: string) {
|
||||
let outputsBegin;
|
||||
if (this._activeCellGuid === cellGuid) {
|
||||
outputsBegin = this._outputBeginRange;
|
||||
@@ -272,7 +272,7 @@ export class NotebookTextFileModel {
|
||||
}
|
||||
|
||||
// Determine what text needs to be replaced when execution counts are updated
|
||||
private getExecutionCountRange(textEditorModel: BaseTextEditorModel, cellGuid: string) {
|
||||
private getExecutionCountRange(textEditorModel: ITextEditorModel, cellGuid: string) {
|
||||
let endOutputRange = this.getEndOfOutputs(textEditorModel, cellGuid);
|
||||
if (endOutputRange && endOutputRange.endLineNumber) {
|
||||
return textEditorModel.textEditorModel.findNextMatch('"execution_count": ', { lineNumber: endOutputRange.endLineNumber, column: endOutputRange.endColumn }, false, true, undefined, true);
|
||||
@@ -282,14 +282,14 @@ export class NotebookTextFileModel {
|
||||
|
||||
// Find a cell's location, given its cellGuid
|
||||
// If it doesn't exist (e.g. it's not the active cell), attempt to find it
|
||||
private getCellNodeByGuid(textEditorModel: BaseTextEditorModel, guid: string) {
|
||||
private getCellNodeByGuid(textEditorModel: ITextEditorModel, guid: string) {
|
||||
if (this._activeCellGuid !== guid || !this._sourceBeginRange) {
|
||||
this.updateSourceBeginRange(textEditorModel, guid);
|
||||
}
|
||||
return this._sourceBeginRange;
|
||||
}
|
||||
|
||||
private getOutputNodeByGuid(textEditorModel: BaseTextEditorModel, guid: string) {
|
||||
private getOutputNodeByGuid(textEditorModel: ITextEditorModel, guid: string) {
|
||||
if (this._activeCellGuid !== guid) {
|
||||
this.updateOutputBeginRange(textEditorModel, guid);
|
||||
}
|
||||
@@ -302,7 +302,7 @@ function areRangePropertiesPopulated(range: Range) {
|
||||
return range && range.startLineNumber !== 0 && range.startColumn !== 0 && range.endLineNumber !== 0 && range.endColumn !== 0;
|
||||
}
|
||||
|
||||
function findOrSetCellGuidMatch(textEditorModel: BaseTextEditorModel, cellGuid: string): FindMatch[] {
|
||||
function findOrSetCellGuidMatch(textEditorModel: ITextEditorModel, cellGuid: string): FindMatch[] {
|
||||
if (!textEditorModel || !cellGuid) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user