diff --git a/src/vs/platform/quickinput/common/quickInput.ts b/src/vs/platform/quickinput/common/quickInput.ts index 4f6d33febf1..f19d33f8318 100644 --- a/src/vs/platform/quickinput/common/quickInput.ts +++ b/src/vs/platform/quickinput/common/quickInput.ts @@ -114,7 +114,7 @@ export interface IInputOptions { /** * an optional function that is used to validate user input. */ - validateInput?: (input: string) => Promise; + validateInput?: (input: string) => Promise; } export interface IQuickInput { diff --git a/src/vs/workbench/api/node/extHost.protocol.ts b/src/vs/workbench/api/node/extHost.protocol.ts index 24b5c1b024a..cfafeed72ac 100644 --- a/src/vs/workbench/api/node/extHost.protocol.ts +++ b/src/vs/workbench/api/node/extHost.protocol.ts @@ -939,7 +939,7 @@ export interface ExtHostLanguageFeaturesShape { export interface ExtHostQuickOpenShape { $onItemSelected(handle: number): void; - $validateInput(input: string): Promise; + $validateInput(input: string): Promise; $onDidChangeActive(sessionId: number, handles: number[]): void; $onDidChangeSelection(sessionId: number, handles: number[]): void; $onDidAccept(sessionId: number): void; diff --git a/src/vs/workbench/api/node/extHostQuickOpen.ts b/src/vs/workbench/api/node/extHostQuickOpen.ts index ab869c83dc0..c2a196eb685 100644 --- a/src/vs/workbench/api/node/extHostQuickOpen.ts +++ b/src/vs/workbench/api/node/extHostQuickOpen.ts @@ -25,7 +25,7 @@ export class ExtHostQuickOpen implements ExtHostQuickOpenShape { private _commands: ExtHostCommands; private _onDidSelectItem: (handle: number) => void; - private _validateInput: (input: string) => string | Thenable; + private _validateInput?: (input: string) => string | undefined | null | Thenable; private _sessions = new Map(); @@ -72,10 +72,10 @@ export class ExtHostQuickOpen implements ExtHostQuickOpenShape { let item = items[handle]; let label: string; - let description: string; - let detail: string; - let picked: boolean; - let alwaysShow: boolean; + let description: string | undefined; + let detail: string | undefined; + let picked: boolean | undefined; + let alwaysShow: boolean | undefined; if (typeof item === 'string') { label = item; @@ -99,7 +99,7 @@ export class ExtHostQuickOpen implements ExtHostQuickOpenShape { // handle selection changes if (options && typeof options.onDidSelectItem === 'function') { this._onDidSelectItem = (handle) => { - options.onDidSelectItem(items[handle]); + options.onDidSelectItem!(items[handle]); }; } @@ -137,7 +137,7 @@ export class ExtHostQuickOpen implements ExtHostQuickOpenShape { showInput(options?: InputBoxOptions, token: CancellationToken = CancellationToken.None): Promise { // global validate fn used in callback below - this._validateInput = options && options.validateInput; + this._validateInput = options ? options.validateInput : undefined; return this._proxy.$input(options, typeof this._validateInput === 'function', token) .then(undefined, err => { @@ -149,11 +149,11 @@ export class ExtHostQuickOpen implements ExtHostQuickOpenShape { }); } - $validateInput(input: string): Promise { + $validateInput(input: string): Promise { if (this._validateInput) { - return asPromise(() => this._validateInput(input)); + return asPromise(() => this._validateInput!(input)); } - return undefined; + return Promise.resolve(undefined); } // ---- workspace folder picker diff --git a/src/vs/workbench/browser/parts/quickinput/quickInput.ts b/src/vs/workbench/browser/parts/quickinput/quickInput.ts index f0458b7bbff..4754a2ed545 100644 --- a/src/vs/workbench/browser/parts/quickinput/quickInput.ts +++ b/src/vs/workbench/browser/parts/quickinput/quickInput.ts @@ -1162,7 +1162,7 @@ export class QuickInputService extends Component implements IQuickInputService { } validation.then(result => { if (value === validationValue) { - input.validationMessage = result; + input.validationMessage = result === null ? undefined : result; } }); }),