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

Strict null check findInput

上级 c25b7499
...@@ -31,6 +31,7 @@ ...@@ -31,6 +31,7 @@
"./vs/base/browser/ui/checkbox/checkbox.ts", "./vs/base/browser/ui/checkbox/checkbox.ts",
"./vs/base/browser/ui/contextview/contextview.ts", "./vs/base/browser/ui/contextview/contextview.ts",
"./vs/base/browser/ui/countBadge/countBadge.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/findinput/findInputCheckboxes.ts",
"./vs/base/browser/ui/grid/grid.ts", "./vs/base/browser/ui/grid/grid.ts",
"./vs/base/browser/ui/grid/gridview.ts", "./vs/base/browser/ui/grid/gridview.ts",
......
...@@ -44,24 +44,24 @@ export class FindInput extends Widget { ...@@ -44,24 +44,24 @@ export class FindInput extends Widget {
private contextViewProvider: IContextViewProvider; private contextViewProvider: IContextViewProvider;
private width: number; private width: number;
private placeholder: string; private placeholder: string;
private validation: IInputValidator; private validation?: IInputValidator;
private label: string; private label: string;
private fixFocusOnOptionClickEnabled = true; private fixFocusOnOptionClickEnabled = true;
private inputActiveOptionBorder: Color; private inputActiveOptionBorder?: Color;
private inputBackground: Color; private inputBackground?: Color;
private inputForeground: Color; private inputForeground?: Color;
private inputBorder: Color; private inputBorder?: Color;
private inputValidationInfoBorder: Color; private inputValidationInfoBorder?: Color;
private inputValidationInfoBackground: Color; private inputValidationInfoBackground?: Color;
private inputValidationInfoForeground: Color; private inputValidationInfoForeground?: Color;
private inputValidationWarningBorder: Color; private inputValidationWarningBorder?: Color;
private inputValidationWarningBackground: Color; private inputValidationWarningBackground?: Color;
private inputValidationWarningForeground: Color; private inputValidationWarningForeground?: Color;
private inputValidationErrorBorder: Color; private inputValidationErrorBorder?: Color;
private inputValidationErrorBackground: Color; private inputValidationErrorBackground?: Color;
private inputValidationErrorForeground: Color; private inputValidationErrorForeground?: Color;
private regex: RegexCheckbox; private regex: RegexCheckbox;
private wholeWords: WholeWordsCheckbox; private wholeWords: WholeWordsCheckbox;
...@@ -90,7 +90,7 @@ export class FindInput extends Widget { ...@@ -90,7 +90,7 @@ export class FindInput extends Widget {
private _onRegexKeyDown = this._register(new Emitter<IKeyboardEvent>()); private _onRegexKeyDown = this._register(new Emitter<IKeyboardEvent>());
public readonly onRegexKeyDown: Event<IKeyboardEvent> = this._onRegexKeyDown.event; 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(); super();
this.contextViewProvider = contextViewProvider; this.contextViewProvider = contextViewProvider;
this.width = options.width || 100; this.width = options.width || 100;
...@@ -113,13 +113,7 @@ export class FindInput extends Widget { ...@@ -113,13 +113,7 @@ export class FindInput extends Widget {
this.inputValidationErrorBackground = options.inputValidationErrorBackground; this.inputValidationErrorBackground = options.inputValidationErrorBackground;
this.inputValidationErrorForeground = options.inputValidationErrorForeground; this.inputValidationErrorForeground = options.inputValidationErrorForeground;
this.regex = null; this.buildDomNode(options.appendCaseSensitiveLabel || '', options.appendWholeWordsLabel || '', options.appendRegexLabel || '', options.history || [], !!options.flexibleHeight);
this.wholeWords = null;
this.caseSensitive = null;
this.domNode = null;
this.inputBox = null;
this.buildDomNode(options.appendCaseSensitiveLabel || '', options.appendWholeWordsLabel || '', options.appendRegexLabel || '', options.history, options.flexibleHeight);
if (Boolean(parent)) { if (Boolean(parent)) {
parent.appendChild(this.domNode); parent.appendChild(this.domNode);
...@@ -298,7 +292,7 @@ export class FindInput extends Widget { ...@@ -298,7 +292,7 @@ export class FindInput extends Widget {
placeholder: this.placeholder || '', placeholder: this.placeholder || '',
ariaLabel: this.label || '', ariaLabel: this.label || '',
validationOptions: { validationOptions: {
validation: this.validation || null validation: this.validation
}, },
inputBackground: this.inputBackground, inputBackground: this.inputBackground,
inputForeground: this.inputForeground, inputForeground: this.inputForeground,
...@@ -370,7 +364,7 @@ export class FindInput extends Widget { ...@@ -370,7 +364,7 @@ export class FindInput extends Widget {
if (event.equals(KeyCode.LeftArrow) || event.equals(KeyCode.RightArrow) || event.equals(KeyCode.Escape)) { if (event.equals(KeyCode.LeftArrow) || event.equals(KeyCode.RightArrow) || event.equals(KeyCode.Escape)) {
let index = indexes.indexOf(<HTMLElement>document.activeElement); let index = indexes.indexOf(<HTMLElement>document.activeElement);
if (index >= 0) { if (index >= 0) {
let newIndex: number; let newIndex: number = -1;
if (event.equals(KeyCode.RightArrow)) { if (event.equals(KeyCode.RightArrow)) {
newIndex = (index + 1) % indexes.length; newIndex = (index + 1) % indexes.length;
} else if (event.equals(KeyCode.LeftArrow)) { } else if (event.equals(KeyCode.LeftArrow)) {
...@@ -405,19 +399,27 @@ export class FindInput extends Widget { ...@@ -405,19 +399,27 @@ export class FindInput extends Widget {
} }
public validate(): void { public validate(): void {
this.inputBox.validate(); if (this.inputBox) {
this.inputBox.validate();
}
} }
public showMessage(message: InputBoxMessage): void { public showMessage(message: InputBoxMessage): void {
this.inputBox.showMessage(message); if (this.inputBox) {
this.inputBox.showMessage(message);
}
} }
public clearMessage(): void { public clearMessage(): void {
this.inputBox.hideMessage(); if (this.inputBox) {
this.inputBox.hideMessage();
}
} }
private clearValidation(): void { private clearValidation(): void {
this.inputBox.hideMessage(); if (this.inputBox) {
this.inputBox.hideMessage();
}
} }
public dispose(): void { public dispose(): void {
......
...@@ -57,7 +57,7 @@ export interface IMessage { ...@@ -57,7 +57,7 @@ export interface IMessage {
} }
export interface IInputValidationOptions { export interface IInputValidationOptions {
validation: IInputValidator; validation?: IInputValidator;
} }
export const enum MessageType { export const enum MessageType {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册