提交 f97736cc 编写于 作者: M Matt Bierner

Strict null check findInput

上级 c25b7499
......@@ -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",
......
......@@ -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<IKeyboardEvent>());
public readonly onRegexKeyDown: Event<IKeyboardEvent> = 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(<HTMLElement>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 {
......
......@@ -57,7 +57,7 @@ export interface IMessage {
}
export interface IInputValidationOptions {
validation: IInputValidator;
validation?: IInputValidator;
}
export const enum MessageType {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册