An event that is fired when a {@link NotebookDocument notebook document} will be saved.

To make modifications to the document before it is being saved, call the {@linkcode NotebookDocumentWillSaveEvent.waitUntil waitUntil}-function with a thenable that resolves to a {@link WorkspaceEdit workspace edit}.

Variables

read onlynotebook:NotebookDocument

The {@link NotebookDocument notebook document} that will be saved.

read onlyreason:TextDocumentSaveReason

The reason why save was triggered.

read onlytoken:CancellationToken

A cancellation token.

Methods

waitUntil(thenable:Thenable<WorkspaceEdit>):Void

waitUntil(thenable:Thenable<Any>):Void

Allows to pause the event loop and to apply {@link WorkspaceEdit workspace edit}. Edits of subsequent calls to this function will be applied in order. The edits will be ignored if concurrent modifications of the notebook document happened.

Note: This function can only be called during event dispatch and not in an asynchronous manner:

workspace.onWillSaveNotebookDocument(event => {
	// async, will *throw* an error
	setTimeout(() => event.waitUntil(promise));

	// sync, OK
	event.waitUntil(promise);
})

@link WorkspaceEdit workspace edit}.

Parameters:

thenable

A thenable that resolves to {