提交 8ef18acd 编写于 作者: M Matt Bierner

Don't require return value backup

Fixes #91703

All custom editors should implement backup or throw an exception if they cannot for some reason.
上级 06529506
......@@ -1273,7 +1273,7 @@ declare module 'vscode' {
* in an operation that takes time to complete, your extension may decide to finish the ongoing backup rather
* than cancelling it to ensure that VS Code has some valid backup.
*/
backup(cancellation: CancellationToken): Thenable<boolean>;
backup(cancellation: CancellationToken): Thenable<void>;
}
/**
......
......@@ -620,7 +620,7 @@ export interface ExtHostWebviewsShape {
$onSave(resource: UriComponents, viewType: string): Promise<void>;
$onSaveAs(resource: UriComponents, viewType: string, targetResource: UriComponents): Promise<void>;
$backup(resource: UriComponents, viewType: string, cancellation: CancellationToken): Promise<boolean>;
$backup(resource: UriComponents, viewType: string, cancellation: CancellationToken): Promise<void>;
}
export interface MainThreadUrlsShape extends IDisposable {
......
......@@ -727,7 +727,7 @@ export class ExtHostWebviews implements ExtHostWebviewsShape {
return document._saveAs(URI.revive(targetResource));
}
async $backup(resourceComponents: UriComponents, viewType: string, cancellation: CancellationToken): Promise<boolean> {
async $backup(resourceComponents: UriComponents, viewType: string, cancellation: CancellationToken): Promise<void> {
const document = this.getDocument(viewType, resourceComponents);
return document._backup(cancellation);
}
......
......@@ -74,7 +74,7 @@ export interface ICustomEditorModel extends IWorkingCopy {
readonly onWillSave: Event<CustomEditorSaveEvent>;
readonly onWillSaveAs: Event<CustomEditorSaveAsEvent>;
onBackup(f: () => CancelablePromise<boolean>): void;
onBackup(f: () => CancelablePromise<void>): void;
setDirty(dirty: boolean): void;
undo(): void;
......
......@@ -29,7 +29,7 @@ namespace HotExitState {
readonly type = Type.Pending;
constructor(
public readonly operation: CancelablePromise<boolean>,
public readonly operation: CancelablePromise<void>,
) { }
}
......@@ -90,9 +90,9 @@ export class CustomEditorModel extends Disposable implements ICustomEditorModel
private readonly _onWillSaveAs = this._register(new Emitter<CustomEditorSaveAsEvent>());
public readonly onWillSaveAs = this._onWillSaveAs.event;
private _onBackup: undefined | (() => CancelablePromise<boolean>);
private _onBackup: undefined | (() => CancelablePromise<void>);
public onBackup(f: () => CancelablePromise<boolean>) {
public onBackup(f: () => CancelablePromise<void>) {
if (this._onBackup) {
throw new Error('Backup already implemented');
}
......@@ -182,7 +182,11 @@ export class CustomEditorModel extends Disposable implements ICustomEditorModel
this._hotExitState = pendingState;
try {
this._hotExitState = await pendingState.operation ? HotExitState.Allowed : HotExitState.NotAllowed;
await pendingState.operation;
// Make sure state has not changed in the meantime
if (this._hotExitState === pendingState) {
this._hotExitState = HotExitState.Allowed;
}
} catch (e) {
// Make sure state has not changed in the meantime
if (this._hotExitState === pendingState) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册