mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-01-17 09:35:37 -05:00
Add saved and executed events to notebook changed (#5848)
- Updated the notebook API to add a change kind, and support saved, executed and other simplified status - Plumbed this through to the main thread classes - Support sending the events from cell / input to the notebook model so they loop over the extension host as a content changed event - Add executed event from the cell
This commit is contained in:
@@ -147,7 +147,7 @@ export class ExtHostNotebookDocumentsAndEditors implements ExtHostNotebookDocume
|
||||
this._onDidChangeNotebookCell.fire({
|
||||
cells: data.document.cells,
|
||||
notebook: data.document,
|
||||
kind: undefined
|
||||
kind: e.changeKind
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ import {
|
||||
} from 'sql/workbench/api/node/sqlExtHost.protocol';
|
||||
import { NotebookInput } from 'sql/workbench/parts/notebook/notebookInput';
|
||||
import { INotebookService, INotebookEditor, IProviderInfo } from 'sql/workbench/services/notebook/common/notebookService';
|
||||
import { ISingleNotebookEditOperation } from 'sql/workbench/api/common/sqlExtHostTypes';
|
||||
import { ISingleNotebookEditOperation, NotebookChangeKind } from 'sql/workbench/api/common/sqlExtHostTypes';
|
||||
import { disposed } from 'vs/base/common/errors';
|
||||
import { ICellModel, NotebookContentChange, INotebookModel } from 'sql/workbench/parts/notebook/models/modelInterfaces';
|
||||
import { NotebookChangeType, CellTypes } from 'sql/workbench/parts/notebook/models/contracts';
|
||||
@@ -564,11 +564,32 @@ export class MainThreadNotebookDocumentsAndEditors extends Disposable implements
|
||||
providerId: editor.providerId,
|
||||
providers: editor.providers,
|
||||
uri: editor.uri,
|
||||
kernelSpec: this.getKernelSpec(editor)
|
||||
kernelSpec: this.getKernelSpec(editor),
|
||||
changeKind: this.mapChangeKind(e.changeType)
|
||||
};
|
||||
return changeData;
|
||||
}
|
||||
|
||||
mapChangeKind(changeType: NotebookChangeType): NotebookChangeKind {
|
||||
switch (changeType) {
|
||||
case NotebookChangeType.CellDeleted:
|
||||
case NotebookChangeType.CellsAdded:
|
||||
case NotebookChangeType.CellOutputUpdated:
|
||||
case NotebookChangeType.CellSourceUpdated:
|
||||
case NotebookChangeType.DirtyStateChanged:
|
||||
return NotebookChangeKind.ContentUpdated;
|
||||
case NotebookChangeType.KernelChanged:
|
||||
case NotebookChangeType.TrustChanged:
|
||||
return NotebookChangeKind.MetadataUpdated;
|
||||
case NotebookChangeType.Saved:
|
||||
return NotebookChangeKind.Save;
|
||||
case NotebookChangeType.CellExecuted:
|
||||
return NotebookChangeKind.CellExecuted;
|
||||
default:
|
||||
return NotebookChangeKind.ContentUpdated;
|
||||
}
|
||||
}
|
||||
|
||||
private getKernelSpec(editor: MainThreadNotebookEditor): azdata.nb.IKernelSpec {
|
||||
let spec = editor && editor.model && editor.model.clientSession ? editor.model.clientSession.cachedKernelSpec : undefined;
|
||||
return spec;
|
||||
|
||||
@@ -496,7 +496,8 @@ export function createApiFactory(
|
||||
registerNotebookProvider(provider: azdata.nb.NotebookProvider): vscode.Disposable {
|
||||
return extHostNotebook.registerNotebookProvider(provider);
|
||||
},
|
||||
CellRange: sqlExtHostTypes.CellRange
|
||||
CellRange: sqlExtHostTypes.CellRange,
|
||||
NotebookChangeKind: sqlExtHostTypes.NotebookChangeKind
|
||||
};
|
||||
|
||||
return {
|
||||
|
||||
@@ -18,7 +18,9 @@ import { ITreeComponentItem } from 'sql/workbench/common/views';
|
||||
import { ITaskHandlerDescription } from 'sql/platform/tasks/common/tasks';
|
||||
import {
|
||||
IItemConfig, IComponentShape, IModelViewDialogDetails, IModelViewTabDetails, IModelViewButtonDetails,
|
||||
IModelViewWizardDetails, IModelViewWizardPageDetails, INotebookManagerDetails, INotebookSessionDetails, INotebookKernelDetails, INotebookFutureDetails, FutureMessageType, INotebookFutureDone, ISingleNotebookEditOperation
|
||||
IModelViewWizardDetails, IModelViewWizardPageDetails, INotebookManagerDetails, INotebookSessionDetails,
|
||||
INotebookKernelDetails, INotebookFutureDetails, FutureMessageType, INotebookFutureDone, ISingleNotebookEditOperation,
|
||||
NotebookChangeKind
|
||||
} from 'sql/workbench/api/common/sqlExtHostTypes';
|
||||
import { EditorViewColumn } from 'vs/workbench/api/common/shared/editor';
|
||||
import { IUndoStopOptions } from 'vs/workbench/api/common/extHost.protocol';
|
||||
@@ -870,6 +872,7 @@ export interface INotebookModelChangedData {
|
||||
isDirty: boolean;
|
||||
cells: azdata.nb.NotebookCell[];
|
||||
kernelSpec: azdata.nb.IKernelSpec;
|
||||
changeKind: NotebookChangeKind;
|
||||
}
|
||||
|
||||
export interface INotebookEditorAddData {
|
||||
|
||||
Reference in New Issue
Block a user