提交 e42a46ab 编写于 作者: R rebornix

Notebook document content options.

上级 d45d4ca3
......@@ -1367,6 +1367,20 @@ declare module 'vscode' {
runState?: NotebookRunState;
}
export interface NotebookDocumentContentOptions {
/**
* Controls if outputs change will trigger notebook document content change and if it will be used in the diff editor
* Default to false. If the content provider doesn't persisit the outputs in the file document, this should be set to true.
*/
transientOutputs: boolean;
/**
* Controls if a meetadata property change will trigger notebook document content change and if it will be used in the diff editor
* Default to false. If the content provider doesn't persisit a metadata property in the file document, it should be set to true.
*/
transientMetadata: { [K in keyof NotebookCellMetadata]?: boolean };
}
export interface NotebookDocument {
readonly uri: Uri;
readonly version: number;
......@@ -1375,6 +1389,7 @@ declare module 'vscode' {
readonly isDirty: boolean;
readonly isUntitled: boolean;
readonly cells: ReadonlyArray<NotebookCell>;
readonly contentOptions: NotebookDocumentContentOptions;
languages: string[];
metadata: NotebookDocumentMetadata;
}
......@@ -1781,18 +1796,7 @@ declare module 'vscode' {
export function registerNotebookContentProvider(
notebookType: string,
provider: NotebookContentProvider,
options?: {
/**
* Controls if outputs change will trigger notebook document content change and if it will be used in the diff editor
* Default to false. If the content provider doesn't persisit the outputs in the file document, this should be set to true.
*/
transientOutputs: boolean;
/**
* Controls if a meetadata property change will trigger notebook document content change and if it will be used in the diff editor
* Default to false. If the content provider doesn't persisit a metadata property in the file document, it should be set to true.
*/
transientMetadata: { [K in keyof NotebookCellMetadata]?: boolean };
options?: NotebookDocumentContentOptions & {
/**
* Not ready for production or development use yet.
*/
......
......@@ -105,6 +105,7 @@ class DocumentAndEditorState {
outputs: cell.outputs,
metadata: cell.metadata
})),
contentOptions: e.transientOptions,
// attachedEditor: editorId ? {
// id: editorId,
// selections: document.textModel.selections
......
......@@ -1667,6 +1667,7 @@ export interface INotebookModelAddedData {
viewType: string;
metadata?: NotebookDocumentMetadata;
attachedEditor?: { id: string; selections: number[]; visibleRanges: ICellRange[] }
contentOptions: { transientOutputs: boolean; transientMetadata: TransientMetadata; }
}
export interface INotebookEditorAddData {
......
......@@ -729,7 +729,7 @@ export class ExtHostNotebookController implements ExtHostNotebookShape, ExtHostN
emitDocumentMetadataChange(event: vscode.NotebookDocumentMetadataChangeEvent): void {
that._onDidChangeNotebookDocumentMetadata.fire(event);
}
}, viewType, { ...notebookDocumentMetadataDefaults, ...modelData.metadata }, uri, storageRoot);
}, viewType, modelData.contentOptions, { ...notebookDocumentMetadataDefaults, ...modelData.metadata }, uri, storageRoot);
document.acceptModelChanged({
versionId: modelData.versionId,
......
......@@ -236,6 +236,7 @@ export class ExtHostNotebookDocument extends Disposable {
private readonly _mainThreadBulkEdits: MainThreadBulkEditsShape,
private readonly _emitter: INotebookEventEmitter,
private readonly _viewType: string,
private readonly _contentOptions: vscode.NotebookDocumentContentOptions,
metadata: Required<vscode.NotebookDocumentMetadata>,
public readonly uri: URI,
private readonly _storagePath: URI | undefined
......@@ -301,6 +302,7 @@ export class ExtHostNotebookDocument extends Disposable {
set languages(value: string[]) { that._trySetLanguages(value); },
get metadata() { return that._metadata; },
set metadata(value: Required<vscode.NotebookDocumentMetadata>) { that._updateMetadata(value); },
get contentOptions() { return that._contentOptions; }
});
}
return this._notebook;
......
......@@ -77,6 +77,7 @@ suite('NotebookCell#Document', function () {
cellKind: CellKind.Code,
outputs: [],
}],
contentOptions: { transientMetadata: {}, transientOutputs: false }
}],
addedEditors: [{
documentUri: notebookUri,
......
......@@ -68,6 +68,7 @@ suite('NotebookConcatDocument', function () {
cellKind: CellKind.Markdown,
outputs: [],
}],
contentOptions: { transientOutputs: false, transientMetadata: {} },
versionId: 0
}],
addedEditors: [
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册