Skip to content

Commit

Permalink
#50583 Adopt findInput to use HistoryInputBox
Browse files Browse the repository at this point in the history
  • Loading branch information
sandy081 committed Jun 7, 2018
1 parent fc86ba3 commit 315ec62
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions src/vs/base/browser/ui/findinput/findInput.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import 'vs/css!./findInput';

import * as nls from 'vs/nls';
import * as dom from 'vs/base/browser/dom';
import { IMessage as InputBoxMessage, IInputValidator, InputBox, IInputBoxStyles } from 'vs/base/browser/ui/inputbox/inputBox';
import { IMessage as InputBoxMessage, IInputValidator, IInputBoxStyles, HistoryInputBox } from 'vs/base/browser/ui/inputbox/inputBox';
import { IContextViewProvider } from 'vs/base/browser/ui/contextview/contextview';
import { Widget } from 'vs/base/browser/ui/widget';
import { Event, Emitter } from 'vs/base/common/event';
Expand All @@ -28,6 +28,7 @@ export interface IFindInputOptions extends IFindInputStyles {
readonly appendCaseSensitiveLabel?: string;
readonly appendWholeWordsLabel?: string;
readonly appendRegexLabel?: string;
readonly history?: string[];
}

export interface IFindInputStyles extends IInputBoxStyles {
Expand Down Expand Up @@ -62,7 +63,7 @@ export class FindInput extends Widget {
private wholeWords: WholeWordsCheckbox;
private caseSensitive: CaseSensitiveCheckbox;
public domNode: HTMLElement;
public inputBox: InputBox;
public inputBox: HistoryInputBox;

private readonly _onDidOptionChange = this._register(new Emitter<boolean>());
public readonly onDidOptionChange: Event<boolean /* via keyboard */> = this._onDidOptionChange.event;
Expand Down Expand Up @@ -108,7 +109,7 @@ export class FindInput extends Widget {
this.domNode = null;
this.inputBox = null;

this.buildDomNode(options.appendCaseSensitiveLabel || '', options.appendWholeWordsLabel || '', options.appendRegexLabel || '');
this.buildDomNode(options.appendCaseSensitiveLabel || '', options.appendWholeWordsLabel || '', options.appendRegexLabel || '', options.history);

if (Boolean(parent)) {
parent.appendChild(this.domNode);
Expand Down Expand Up @@ -259,12 +260,12 @@ export class FindInput extends Widget {
this.inputBox.width = w;
}

private buildDomNode(appendCaseSensitiveLabel: string, appendWholeWordsLabel: string, appendRegexLabel: string): void {
private buildDomNode(appendCaseSensitiveLabel: string, appendWholeWordsLabel: string, appendRegexLabel: string, history: string[]): void {
this.domNode = document.createElement('div');
this.domNode.style.width = this.width + 'px';
dom.addClass(this.domNode, 'monaco-findInput');

this.inputBox = this._register(new InputBox(this.domNode, this.contextViewProvider, {
this.inputBox = this._register(new HistoryInputBox(this.domNode, this.contextViewProvider, {
placeholder: this.placeholder || '',
ariaLabel: this.label || '',
validationOptions: {
Expand All @@ -278,7 +279,8 @@ export class FindInput extends Widget {
inputValidationWarningBackground: this.inputValidationWarningBackground,
inputValidationWarningBorder: this.inputValidationWarningBorder,
inputValidationErrorBackground: this.inputValidationErrorBackground,
inputValidationErrorBorder: this.inputValidationErrorBorder
inputValidationErrorBorder: this.inputValidationErrorBorder,
history
}));

this.regex = this._register(new RegexCheckbox({
Expand Down

0 comments on commit 315ec62

Please sign in to comment.