diff --git a/src/tsconfig.strictNullChecks.json b/src/tsconfig.strictNullChecks.json index 4bce8607d066793de65568c1bf886485e523a9df..4390a2ed85c124da023e81ee50ed0afc1a53bacc 100644 --- a/src/tsconfig.strictNullChecks.json +++ b/src/tsconfig.strictNullChecks.json @@ -31,6 +31,7 @@ "./vs/base/browser/ui/checkbox/checkbox.ts", "./vs/base/browser/ui/contextview/contextview.ts", "./vs/base/browser/ui/countBadge/countBadge.ts", + "./vs/base/browser/ui/findinput/findInput.ts", "./vs/base/browser/ui/findinput/findInputCheckboxes.ts", "./vs/base/browser/ui/grid/grid.ts", "./vs/base/browser/ui/grid/gridview.ts", diff --git a/src/vs/base/browser/ui/findinput/findInput.ts b/src/vs/base/browser/ui/findinput/findInput.ts index df0567032a31c76963c4a6648c5f13b0814b8fd6..737c69da3b482a1b9899df31507fb3ecc7328e9c 100644 --- a/src/vs/base/browser/ui/findinput/findInput.ts +++ b/src/vs/base/browser/ui/findinput/findInput.ts @@ -44,24 +44,24 @@ export class FindInput extends Widget { private contextViewProvider: IContextViewProvider; private width: number; private placeholder: string; - private validation: IInputValidator; + private validation?: IInputValidator; private label: string; private fixFocusOnOptionClickEnabled = true; - private inputActiveOptionBorder: Color; - private inputBackground: Color; - private inputForeground: Color; - private inputBorder: Color; - - private inputValidationInfoBorder: Color; - private inputValidationInfoBackground: Color; - private inputValidationInfoForeground: Color; - private inputValidationWarningBorder: Color; - private inputValidationWarningBackground: Color; - private inputValidationWarningForeground: Color; - private inputValidationErrorBorder: Color; - private inputValidationErrorBackground: Color; - private inputValidationErrorForeground: Color; + private inputActiveOptionBorder?: Color; + private inputBackground?: Color; + private inputForeground?: Color; + private inputBorder?: Color; + + private inputValidationInfoBorder?: Color; + private inputValidationInfoBackground?: Color; + private inputValidationInfoForeground?: Color; + private inputValidationWarningBorder?: Color; + private inputValidationWarningBackground?: Color; + private inputValidationWarningForeground?: Color; + private inputValidationErrorBorder?: Color; + private inputValidationErrorBackground?: Color; + private inputValidationErrorForeground?: Color; private regex: RegexCheckbox; private wholeWords: WholeWordsCheckbox; @@ -90,7 +90,7 @@ export class FindInput extends Widget { private _onRegexKeyDown = this._register(new Emitter()); public readonly onRegexKeyDown: Event = this._onRegexKeyDown.event; - constructor(parent: HTMLElement, contextViewProvider: IContextViewProvider, private readonly _showOptionButtons: boolean, options?: IFindInputOptions) { + constructor(parent: HTMLElement, contextViewProvider: IContextViewProvider, private readonly _showOptionButtons: boolean, options: IFindInputOptions) { super(); this.contextViewProvider = contextViewProvider; this.width = options.width || 100; @@ -113,13 +113,7 @@ export class FindInput extends Widget { this.inputValidationErrorBackground = options.inputValidationErrorBackground; this.inputValidationErrorForeground = options.inputValidationErrorForeground; - this.regex = null; - this.wholeWords = null; - this.caseSensitive = null; - this.domNode = null; - this.inputBox = null; - - this.buildDomNode(options.appendCaseSensitiveLabel || '', options.appendWholeWordsLabel || '', options.appendRegexLabel || '', options.history, options.flexibleHeight); + this.buildDomNode(options.appendCaseSensitiveLabel || '', options.appendWholeWordsLabel || '', options.appendRegexLabel || '', options.history || [], !!options.flexibleHeight); if (Boolean(parent)) { parent.appendChild(this.domNode); @@ -298,7 +292,7 @@ export class FindInput extends Widget { placeholder: this.placeholder || '', ariaLabel: this.label || '', validationOptions: { - validation: this.validation || null + validation: this.validation }, inputBackground: this.inputBackground, inputForeground: this.inputForeground, @@ -370,7 +364,7 @@ export class FindInput extends Widget { if (event.equals(KeyCode.LeftArrow) || event.equals(KeyCode.RightArrow) || event.equals(KeyCode.Escape)) { let index = indexes.indexOf(document.activeElement); if (index >= 0) { - let newIndex: number; + let newIndex: number = -1; if (event.equals(KeyCode.RightArrow)) { newIndex = (index + 1) % indexes.length; } else if (event.equals(KeyCode.LeftArrow)) { @@ -405,19 +399,27 @@ export class FindInput extends Widget { } public validate(): void { - this.inputBox.validate(); + if (this.inputBox) { + this.inputBox.validate(); + } } public showMessage(message: InputBoxMessage): void { - this.inputBox.showMessage(message); + if (this.inputBox) { + this.inputBox.showMessage(message); + } } public clearMessage(): void { - this.inputBox.hideMessage(); + if (this.inputBox) { + this.inputBox.hideMessage(); + } } private clearValidation(): void { - this.inputBox.hideMessage(); + if (this.inputBox) { + this.inputBox.hideMessage(); + } } public dispose(): void { diff --git a/src/vs/base/browser/ui/inputbox/inputBox.ts b/src/vs/base/browser/ui/inputbox/inputBox.ts index 055e5bfb59d613a12f090570e3da80f88238d37b..49e86d2226e972e55591b75bfa1f8f4df1bfe4ff 100644 --- a/src/vs/base/browser/ui/inputbox/inputBox.ts +++ b/src/vs/base/browser/ui/inputbox/inputBox.ts @@ -57,7 +57,7 @@ export interface IMessage { } export interface IInputValidationOptions { - validation: IInputValidator; + validation?: IInputValidator; } export const enum MessageType {