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

To make modifications to the document before it is being saved, call the {@linkcode TextDocumentWillSaveEvent.waitUntil waitUntil}-function with a thenable that resolves to an array of {@link TextEdit text edits}.

Variables

read onlydocument:TextDocument

The document that will be saved.

read onlyreason:TextDocumentSaveReason

The reason why save was triggered.

Methods

waitUntil(thenable:Thenable<ReadOnlyArray<TextEdit>>):Void

waitUntil(thenable:Thenable<Dynamic>):Void

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

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

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

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

@link TextEdit pre-save-edits}.

Parameters:

thenable

A thenable that resolves to {