Skip to content

Commit 33b3a48

Browse files
committed
Adopt FindInput in QuickInputBox
Part of #156179
1 parent 78cd55a commit 33b3a48

File tree

2 files changed

+32
-31
lines changed

2 files changed

+32
-31
lines changed

src/vs/base/browser/ui/findinput/findInput.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ export class FindInput extends Widget {
4747

4848
static readonly OPTION_CHANGE: string = 'optionChange';
4949

50-
private contextViewProvider: IContextViewProvider;
5150
private placeholder: string;
5251
private validation?: IInputValidator;
5352
private label: string;
@@ -100,9 +99,8 @@ export class FindInput extends Widget {
10099
private _onRegexKeyDown = this._register(new Emitter<IKeyboardEvent>());
101100
public readonly onRegexKeyDown: Event<IKeyboardEvent> = this._onRegexKeyDown.event;
102101

103-
constructor(parent: HTMLElement | null, contextViewProvider: IContextViewProvider, private readonly _showOptionButtons: boolean, options: IFindInputOptions) {
102+
constructor(parent: HTMLElement | null, contextViewProvider: IContextViewProvider | undefined, private readonly _showOptionButtons: boolean, options: IFindInputOptions) {
104103
super();
105-
this.contextViewProvider = contextViewProvider;
106104
this.placeholder = options.placeholder || '';
107105
this.validation = options.validation;
108106
this.label = options.label || NLS_DEFAULT_LABEL;
@@ -135,7 +133,7 @@ export class FindInput extends Widget {
135133
this.domNode = document.createElement('div');
136134
this.domNode.classList.add('monaco-findInput');
137135

138-
this.inputBox = this._register(new HistoryInputBox(this.domNode, this.contextViewProvider, {
136+
this.inputBox = this._register(new HistoryInputBox(this.domNode, contextViewProvider, {
139137
placeholder: this.placeholder || '',
140138
ariaLabel: this.label || '',
141139
validationOptions: {

src/vs/base/parts/quickinput/browser/quickInputBox.ts

Lines changed: 30 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
import * as dom from 'vs/base/browser/dom';
77
import { StandardKeyboardEvent } from 'vs/base/browser/keyboardEvent';
88
import { StandardMouseEvent } from 'vs/base/browser/mouseEvent';
9-
import { IInputBoxStyles, InputBox, IRange, MessageType } from 'vs/base/browser/ui/inputbox/inputBox';
9+
import { FindInput } from 'vs/base/browser/ui/findinput/findInput';
10+
import { IInputBoxStyles, IRange, MessageType } from 'vs/base/browser/ui/inputbox/inputBox';
1011
import { Disposable, IDisposable } from 'vs/base/common/lifecycle';
1112
import Severity from 'vs/base/common/severity';
1213
import 'vs/css!./media/quickInput';
@@ -16,113 +17,115 @@ const $ = dom.$;
1617
export class QuickInputBox extends Disposable {
1718

1819
private container: HTMLElement;
19-
private inputBox: InputBox;
20+
private findInput: FindInput;
2021

2122
constructor(
2223
private parent: HTMLElement
2324
) {
2425
super();
2526
this.container = dom.append(this.parent, $('.quick-input-box'));
26-
this.inputBox = this._register(new InputBox(this.container, undefined));
27+
this.findInput = this._register(new FindInput(this.container, undefined, false, {
28+
label: ''
29+
}));
2730
}
2831

2932
onKeyDown = (handler: (event: StandardKeyboardEvent) => void): IDisposable => {
30-
return dom.addDisposableListener(this.inputBox.inputElement, dom.EventType.KEY_DOWN, (e: KeyboardEvent) => {
33+
return dom.addDisposableListener(this.findInput.inputBox.inputElement, dom.EventType.KEY_DOWN, (e: KeyboardEvent) => {
3134
handler(new StandardKeyboardEvent(e));
3235
});
3336
};
3437

3538
onMouseDown = (handler: (event: StandardMouseEvent) => void): IDisposable => {
36-
return dom.addDisposableListener(this.inputBox.inputElement, dom.EventType.MOUSE_DOWN, (e: MouseEvent) => {
39+
return dom.addDisposableListener(this.findInput.inputBox.inputElement, dom.EventType.MOUSE_DOWN, (e: MouseEvent) => {
3740
handler(new StandardMouseEvent(e));
3841
});
3942
};
4043

4144
onDidChange = (handler: (event: string) => void): IDisposable => {
42-
return this.inputBox.onDidChange(handler);
45+
return this.findInput.onDidChange(handler);
4346
};
4447

4548
get value() {
46-
return this.inputBox.value;
49+
return this.findInput.getValue();
4750
}
4851

4952
set value(value: string) {
50-
this.inputBox.value = value;
53+
this.findInput.setValue(value);
5154
}
5255

5356
select(range: IRange | null = null): void {
54-
this.inputBox.select(range);
57+
this.findInput.inputBox.select(range);
5558
}
5659

5760
isSelectionAtEnd(): boolean {
58-
return this.inputBox.isSelectionAtEnd();
61+
return this.findInput.inputBox.isSelectionAtEnd();
5962
}
6063

6164
setPlaceholder(placeholder: string): void {
62-
this.inputBox.setPlaceHolder(placeholder);
65+
this.findInput.inputBox.setPlaceHolder(placeholder);
6366
}
6467

6568
get placeholder() {
66-
return this.inputBox.inputElement.getAttribute('placeholder') || '';
69+
return this.findInput.inputBox.inputElement.getAttribute('placeholder') || '';
6770
}
6871

6972
set placeholder(placeholder: string) {
70-
this.inputBox.setPlaceHolder(placeholder);
73+
this.findInput.inputBox.setPlaceHolder(placeholder);
7174
}
7275

7376
get ariaLabel() {
74-
return this.inputBox.getAriaLabel();
77+
return this.findInput.inputBox.getAriaLabel();
7578
}
7679

7780
set ariaLabel(ariaLabel: string) {
78-
this.inputBox.setAriaLabel(ariaLabel);
81+
this.findInput.inputBox.setAriaLabel(ariaLabel);
7982
}
8083

8184
get password() {
82-
return this.inputBox.inputElement.type === 'password';
85+
return this.findInput.inputBox.inputElement.type === 'password';
8386
}
8487

8588
set password(password: boolean) {
86-
this.inputBox.inputElement.type = password ? 'password' : 'text';
89+
this.findInput.inputBox.inputElement.type = password ? 'password' : 'text';
8790
}
8891

8992
set enabled(enabled: boolean) {
90-
this.inputBox.setEnabled(enabled);
93+
this.findInput.setEnabled(enabled);
9194
}
9295

9396
hasFocus(): boolean {
94-
return this.inputBox.hasFocus();
97+
return this.findInput.inputBox.hasFocus();
9598
}
9699

97100
setAttribute(name: string, value: string): void {
98-
this.inputBox.inputElement.setAttribute(name, value);
101+
this.findInput.inputBox.inputElement.setAttribute(name, value);
99102
}
100103

101104
removeAttribute(name: string): void {
102-
this.inputBox.inputElement.removeAttribute(name);
105+
this.findInput.inputBox.inputElement.removeAttribute(name);
103106
}
104107

105108
showDecoration(decoration: Severity): void {
106109
if (decoration === Severity.Ignore) {
107-
this.inputBox.hideMessage();
110+
this.findInput.clearMessage();
108111
} else {
109-
this.inputBox.showMessage({ type: decoration === Severity.Info ? MessageType.INFO : decoration === Severity.Warning ? MessageType.WARNING : MessageType.ERROR, content: '' });
112+
this.findInput.showMessage({ type: decoration === Severity.Info ? MessageType.INFO : decoration === Severity.Warning ? MessageType.WARNING : MessageType.ERROR, content: '' });
110113
}
111114
}
112115

113116
stylesForType(decoration: Severity) {
114-
return this.inputBox.stylesForType(decoration === Severity.Info ? MessageType.INFO : decoration === Severity.Warning ? MessageType.WARNING : MessageType.ERROR);
117+
return this.findInput.inputBox.stylesForType(decoration === Severity.Info ? MessageType.INFO : decoration === Severity.Warning ? MessageType.WARNING : MessageType.ERROR);
115118
}
116119

117120
setFocus(): void {
118-
this.inputBox.focus();
121+
this.findInput.focus();
119122
}
120123

121124
layout(): void {
122-
this.inputBox.layout();
125+
this.findInput.inputBox.layout();
123126
}
124127

125128
style(styles: IInputBoxStyles): void {
126-
this.inputBox.style(styles);
129+
this.findInput.style(styles);
127130
}
128131
}

0 commit comments

Comments
 (0)