Skip to content

Commit bd6ad55

Browse files
committed
Check in saveAs cancellation
1 parent 7b48811 commit bd6ad55

3 files changed

Lines changed: 6 additions & 4 deletions

File tree

src/vs/workbench/api/browser/mainThreadWebview.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -795,6 +795,7 @@ class MainThreadCustomEditorModel extends Disposable implements ICustomEditorMod
795795
return undefined;
796796
}
797797
// TODO: handle save untitled case
798+
// TODO: handle cancellation
798799
await createCancelablePromise(token => this._proxy.$onSave(this._editorResource, this.viewType, token));
799800
this.change(() => {
800801
this._savePoint = this._currentEditIndex;
@@ -804,7 +805,8 @@ class MainThreadCustomEditorModel extends Disposable implements ICustomEditorMod
804805

805806
public async saveCustomEditorAs(resource: URI, targetResource: URI, _options?: ISaveOptions): Promise<boolean> {
806807
if (this._editable) {
807-
await this._proxy.$onSaveAs(this._editorResource, this.viewType, targetResource);
808+
// TODO: handle cancellation
809+
await createCancelablePromise(token => this._proxy.$onSaveAs(this._editorResource, this.viewType, targetResource, token));
808810
this.change(() => {
809811
this._savePoint = this._currentEditIndex;
810812
});

src/vs/workbench/api/common/extHost.protocol.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -649,7 +649,7 @@ export interface ExtHostWebviewsShape {
649649
$disposeEdits(resourceComponents: UriComponents, viewType: string, editIds: number[]): void;
650650

651651
$onSave(resource: UriComponents, viewType: string, cancellation: CancellationToken): Promise<void>;
652-
$onSaveAs(resource: UriComponents, viewType: string, targetResource: UriComponents): Promise<void>;
652+
$onSaveAs(resource: UriComponents, viewType: string, targetResource: UriComponents, cancellation: CancellationToken): Promise<void>;
653653

654654
$backup(resource: UriComponents, viewType: string, cancellation: CancellationToken): Promise<void>;
655655

src/vs/workbench/api/common/extHostWebview.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -630,10 +630,10 @@ export class ExtHostWebviews implements extHostProtocol.ExtHostWebviewsShape {
630630
return delegate.save(document, cancellation);
631631
}
632632

633-
async $onSaveAs(resourceComponents: UriComponents, viewType: string, targetResource: UriComponents): Promise<void> {
633+
async $onSaveAs(resourceComponents: UriComponents, viewType: string, targetResource: UriComponents, cancellation: CancellationToken): Promise<void> {
634634
const delegate = this.getEditingDelegate(viewType);
635635
const document = this.getCustomDocument(viewType, resourceComponents);
636-
return delegate.saveAs(document, URI.revive(targetResource));
636+
return delegate.saveAs(document, URI.revive(targetResource), cancellation);
637637
}
638638

639639
async $backup(resourceComponents: UriComponents, viewType: string, cancellation: CancellationToken): Promise<void> {

0 commit comments

Comments
 (0)