提交 077cd38d 编写于 作者: M Matt Bierner

Add cancellation on CustomEditor.save

For #91702
上级 415a40e5
......@@ -1227,9 +1227,11 @@ declare module 'vscode' {
/**
* Save the resource.
*
* @param cancellation Token that signals the save is no longer required (for example, if another save was triggered).
*
* @return Thenable signaling that the save has completed.
*/
save(): Thenable<void>;
save(cancellation: CancellationToken): Thenable<void>;
/**
* Save the existing resource at a new path.
......
......@@ -625,7 +625,7 @@ class MainThreadCustomEditorModel extends Disposable implements ICustomEditorMod
if (!this._editable) {
return false;
}
await this._proxy.$onSave(this.resource, this.viewType);
await createCancelablePromise(token => this._proxy.$onSave(this.resource, this.viewType, token));
this.setDirty(false);
return true;
}
......
......@@ -618,7 +618,7 @@ export interface ExtHostWebviewsShape {
$undo(resource: UriComponents, viewType: string): void;
$redo(resource: UriComponents, viewType: string): void;
$revert(resource: UriComponents, viewType: string): void;
$onSave(resource: UriComponents, viewType: string): Promise<void>;
$onSave(resource: UriComponents, viewType: string, cancellation: CancellationToken): Promise<void>;
$onSaveAs(resource: UriComponents, viewType: string, targetResource: UriComponents): Promise<void>;
$backup(resource: UriComponents, viewType: string, cancellation: CancellationToken): Promise<void>;
......
......@@ -350,8 +350,8 @@ class CustomDocument extends Disposable implements vscode.CustomDocument {
this.updateState();
}
/** @internal*/ _save() {
return this.getEditingCapability().save();
/** @internal*/ _save(cancellation: CancellationToken) {
return this.getEditingCapability().save(cancellation);
}
/** @internal*/ _saveAs(target: vscode.Uri) {
......@@ -714,9 +714,9 @@ export class ExtHostWebviews implements ExtHostWebviewsShape {
document._revert();
}
async $onSave(resourceComponents: UriComponents, viewType: string): Promise<void> {
async $onSave(resourceComponents: UriComponents, viewType: string, cancellation: CancellationToken): Promise<void> {
const document = this.getCustomDocument(viewType, resourceComponents);
document._save();
document._save(cancellation);
}
async $onSaveAs(resourceComponents: UriComponents, viewType: string, targetResource: UriComponents): Promise<void> {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册