提交 e42a46ab 编写于 作者: R rebornix

Notebook document content options.

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