Remove WinJS.Promise#cancel usage (#56137)
This commit is contained in:
parent
5ecddfec9c
commit
554c9b1460
3 changed files with 14 additions and 7 deletions
|
@ -5,7 +5,6 @@
|
|||
'use strict';
|
||||
|
||||
import { TPromise } from 'vs/base/common/winjs.base';
|
||||
import { asWinJsPromise } from 'vs/base/common/async';
|
||||
import { IPickOptions, IInputOptions, IQuickInputService, IQuickInput } from 'vs/platform/quickinput/common/quickInput';
|
||||
import { InputBoxOptions } from 'vscode';
|
||||
import { ExtHostContext, MainThreadQuickOpenShape, ExtHostQuickOpenShape, TransferQuickPickItems, MainContext, IExtHostContext, TransferQuickInput, TransferQuickInputButton } from 'vs/workbench/api/node/extHost.protocol';
|
||||
|
@ -98,7 +97,7 @@ export class MainThreadQuickOpen implements MainThreadQuickOpenShape {
|
|||
|
||||
// ---- input
|
||||
|
||||
$input(options: InputBoxOptions, validateInput: boolean): TPromise<string> {
|
||||
$input(options: InputBoxOptions, validateInput: boolean, token: CancellationToken): Thenable<string> {
|
||||
const inputOptions: IInputOptions = Object.create(null);
|
||||
|
||||
if (options) {
|
||||
|
@ -116,7 +115,7 @@ export class MainThreadQuickOpen implements MainThreadQuickOpenShape {
|
|||
};
|
||||
}
|
||||
|
||||
return asWinJsPromise(token => this._quickInputService.input(inputOptions, token));
|
||||
return this._quickInputService.input(inputOptions, token);
|
||||
}
|
||||
|
||||
// ---- QuickInput
|
||||
|
|
|
@ -407,7 +407,7 @@ export interface MainThreadQuickOpenShape extends IDisposable {
|
|||
$show(options: IPickOptions<TransferQuickPickItems>, token: CancellationToken): Thenable<number | number[]>;
|
||||
$setItems(items: TransferQuickPickItems[]): Thenable<void>;
|
||||
$setError(error: Error): Thenable<void>;
|
||||
$input(options: vscode.InputBoxOptions, validateInput: boolean): TPromise<string>;
|
||||
$input(options: vscode.InputBoxOptions, validateInput: boolean, token: CancellationToken): Thenable<string>;
|
||||
$createOrUpdate(params: TransferQuickInput): Thenable<void>;
|
||||
$dispose(id: number): Thenable<void>;
|
||||
}
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
*--------------------------------------------------------------------------------------------*/
|
||||
'use strict';
|
||||
|
||||
import { wireCancellationToken, asThenable } from 'vs/base/common/async';
|
||||
import { asThenable } from 'vs/base/common/async';
|
||||
import { CancellationToken } from 'vs/base/common/cancellation';
|
||||
import { Emitter } from 'vs/base/common/event';
|
||||
import { dispose, IDisposable } from 'vs/base/common/lifecycle';
|
||||
|
@ -130,8 +130,16 @@ export class ExtHostQuickOpen implements ExtHostQuickOpenShape {
|
|||
// global validate fn used in callback below
|
||||
this._validateInput = options && options.validateInput;
|
||||
|
||||
const promise = this._proxy.$input(options, typeof this._validateInput === 'function');
|
||||
return wireCancellationToken(token, promise, true);
|
||||
return this._proxy.$input(options, typeof this._validateInput === 'function', token)
|
||||
.then(null, err => {
|
||||
if (isPromiseCanceledError(err)) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
this._proxy.$setError(err);
|
||||
|
||||
return TPromise.wrapError(err);
|
||||
});
|
||||
}
|
||||
|
||||
$validateInput(input: string): Thenable<string> {
|
||||
|
|
Loading…
Reference in a new issue