mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-01-21 09:35:38 -05:00
Add Notebook Save integration tests (#6103)
* Add Notebook Save integration tests Wrote test to verify save behavior Fixed issues found during testing, specifically around how we notify dirty state change to extensions * Improved error messages
This commit is contained in:
@@ -15,6 +15,7 @@ import { IInstantiationService } from 'vs/platform/instantiation/common/instanti
|
||||
import { ITextEditorOptions } from 'vs/platform/editor/common/editor';
|
||||
import { Schemas } from 'vs/base/common/network';
|
||||
import { ConnectionProfile } from 'sql/platform/connection/common/connectionProfile';
|
||||
import * as types from 'vs/base/common/types';
|
||||
|
||||
import {
|
||||
SqlMainContext, MainThreadNotebookDocumentsAndEditorsShape, SqlExtHostContext, ExtHostNotebookDocumentsAndEditorsShape,
|
||||
@@ -560,7 +561,7 @@ export class MainThreadNotebookDocumentsAndEditors extends Disposable implements
|
||||
let changeData: INotebookModelChangedData = {
|
||||
// Note: we just send all cells for now, not a diff
|
||||
cells: this.convertCellModelToNotebookCell(editor.cells),
|
||||
isDirty: e.isDirty,
|
||||
isDirty: this.getDirtyState(e, editor),
|
||||
providerId: editor.providerId,
|
||||
providers: editor.providers,
|
||||
uri: editor.uri,
|
||||
@@ -570,10 +571,16 @@ export class MainThreadNotebookDocumentsAndEditors extends Disposable implements
|
||||
return changeData;
|
||||
}
|
||||
|
||||
private getDirtyState(e: NotebookContentChange, editor: MainThreadNotebookEditor): boolean {
|
||||
if (!types.isUndefinedOrNull(e.isDirty)) {
|
||||
return e.isDirty;
|
||||
}
|
||||
return editor.isDirty;
|
||||
}
|
||||
|
||||
mapChangeKind(changeType: NotebookChangeType): NotebookChangeKind {
|
||||
switch (changeType) {
|
||||
case NotebookChangeType.CellDeleted:
|
||||
case NotebookChangeType.CellsAdded:
|
||||
case NotebookChangeType.CellsModified:
|
||||
case NotebookChangeType.CellOutputUpdated:
|
||||
case NotebookChangeType.CellSourceUpdated:
|
||||
case NotebookChangeType.DirtyStateChanged:
|
||||
|
||||
@@ -37,8 +37,7 @@ export class OutputTypes {
|
||||
}
|
||||
|
||||
export enum NotebookChangeType {
|
||||
CellsAdded,
|
||||
CellDeleted,
|
||||
CellsModified,
|
||||
CellSourceUpdated,
|
||||
CellOutputUpdated,
|
||||
DirtyStateChanged,
|
||||
|
||||
@@ -341,7 +341,7 @@ export class NotebookModel extends Disposable implements INotebookModel {
|
||||
this.updateActiveCell(cell);
|
||||
|
||||
this._contentChangedEmitter.fire({
|
||||
changeType: NotebookChangeType.CellsAdded,
|
||||
changeType: NotebookChangeType.CellsModified,
|
||||
cells: [cell],
|
||||
cellIndex: index
|
||||
});
|
||||
@@ -375,9 +375,10 @@ export class NotebookModel extends Disposable implements INotebookModel {
|
||||
if (index > -1) {
|
||||
this._cells.splice(index, 1);
|
||||
this._contentChangedEmitter.fire({
|
||||
changeType: NotebookChangeType.CellDeleted,
|
||||
changeType: NotebookChangeType.CellsModified,
|
||||
cells: [cellModel],
|
||||
cellIndex: index
|
||||
cellIndex: index,
|
||||
isDirty: true
|
||||
});
|
||||
} else {
|
||||
this.notifyError(localize('deleteCellFailed', "Failed to delete cell."));
|
||||
@@ -401,7 +402,8 @@ export class NotebookModel extends Disposable implements INotebookModel {
|
||||
this.updateActiveCell(newCells[0]);
|
||||
}
|
||||
this._contentChangedEmitter.fire({
|
||||
changeType: NotebookChangeType.CellsAdded
|
||||
changeType: NotebookChangeType.CellsModified,
|
||||
isDirty: true
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user