Skip to content

Commit dff9f59

Browse files
authored
Merge pull request microsoft#158609 from microsoft/tyriar/156179-options
Move showOptionButtons into IFindInputOptions.showCommonFindToggles
2 parents db4f5a8 + 9034897 commit dff9f59

File tree

10 files changed

+29
-19
lines changed

10 files changed

+29
-19
lines changed

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

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ export interface IFindInputOptions extends IFindInputStyles {
2828
readonly flexibleWidth?: boolean;
2929
readonly flexibleMaxHeight?: number;
3030

31+
readonly showCommonFindToggles?: boolean;
3132
readonly appendCaseSensitiveLabel?: string;
3233
readonly appendWholeWordsLabel?: string;
3334
readonly appendRegexLabel?: string;
@@ -51,6 +52,7 @@ export class FindInput extends Widget {
5152
private placeholder: string;
5253
private validation?: IInputValidator;
5354
private label: string;
55+
private showCommonFindToggles: boolean;
5456
private fixFocusOnOptionClickEnabled = true;
5557
private imeSessionInProgress = false;
5658
private additionalTogglesDisposables: DisposableStore = new DisposableStore();
@@ -101,11 +103,12 @@ export class FindInput extends Widget {
101103
private _onRegexKeyDown = this._register(new Emitter<IKeyboardEvent>());
102104
public readonly onRegexKeyDown: Event<IKeyboardEvent> = this._onRegexKeyDown.event;
103105

104-
constructor(parent: HTMLElement | null, contextViewProvider: IContextViewProvider | undefined, private readonly _showOptionButtons: boolean, options: IFindInputOptions) {
106+
constructor(parent: HTMLElement | null, contextViewProvider: IContextViewProvider | undefined, options: IFindInputOptions) {
105107
super();
106108
this.placeholder = options.placeholder || '';
107109
this.validation = options.validation;
108110
this.label = options.label || NLS_DEFAULT_LABEL;
111+
this.showCommonFindToggles = !!options.showCommonFindToggles;
109112

110113
this.inputActiveOptionBorder = options.inputActiveOptionBorder;
111114
this.inputActiveOptionForeground = options.inputActiveOptionForeground;
@@ -243,12 +246,12 @@ export class FindInput extends Widget {
243246

244247
this.controls = document.createElement('div');
245248
this.controls.className = 'controls';
246-
this.controls.style.display = this._showOptionButtons ? 'block' : 'none';
249+
this.controls.style.display = this.showCommonFindToggles ? 'block' : 'none';
247250
this.controls.appendChild(this.caseSensitive.domNode);
248251
this.controls.appendChild(this.wholeWords.domNode);
249252
this.controls.appendChild(this.regex.domNode);
250253

251-
if (!this._showOptionButtons) {
254+
if (!this.showCommonFindToggles) {
252255
this.caseSensitive.domNode.style.display = 'none';
253256
this.wholeWords.domNode.style.display = 'none';
254257
this.regex.domNode.style.display = 'none';
@@ -345,7 +348,7 @@ export class FindInput extends Widget {
345348
}
346349

347350
this.inputBox.paddingRight =
348-
(this._showOptionButtons ? this.caseSensitive.width() + this.wholeWords.width() + this.regex.width() : 0)
351+
(this.showCommonFindToggles ? this.caseSensitive.width() + this.wholeWords.width() + this.regex.width() : 0)
349352
+ this.additionalToggles.reduce((r, t) => r + t.width(), 0);
350353
}
351354

src/vs/base/browser/ui/tree/abstractTree.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -721,9 +721,10 @@ class FindWidget<T, TFilterData> extends Disposable {
721721
this.modeToggle = this._register(new ModeToggle({ ...options, isChecked: mode === TreeFindMode.Filter }));
722722
this.onDidChangeMode = Event.map(this.modeToggle.onChange, () => this.modeToggle.checked ? TreeFindMode.Filter : TreeFindMode.Highlight, this._store);
723723

724-
this.findInput = this._register(new FindInput(this.elements.findInput, contextViewProvider, false, {
724+
this.findInput = this._register(new FindInput(this.elements.findInput, contextViewProvider, {
725725
label: localize('type to search', "Type to search"),
726-
additionalToggles: [this.modeToggle]
726+
additionalToggles: [this.modeToggle],
727+
showCommonFindToggles: false
727728
}));
728729

729730
this.actionbar = this._register(new ActionBar(this.elements.actionbar));

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ export class QuickInputBox extends Disposable {
2525
) {
2626
super();
2727
this.container = dom.append(this.parent, $('.quick-input-box'));
28-
this.findInput = this._register(new FindInput(this.container, undefined, false, { label: '' }));
28+
this.findInput = this._register(new FindInput(this.container, undefined, { label: '' }));
2929
}
3030

3131
onKeyDown = (handler: (event: StandardKeyboardEvent) => void): IDisposable => {

src/vs/editor/contrib/find/browser/findWidget.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -979,8 +979,9 @@ export class FindWidget extends Widget implements IOverlayWidget, IVerticalSashL
979979
flexibleHeight,
980980
flexibleWidth,
981981
flexibleMaxHeight: 118,
982+
showCommonFindToggles: true,
982983
showHistoryHint: () => showHistoryKeybindingHint(this._keybindingService)
983-
}, this._contextKeyService, true));
984+
}, this._contextKeyService));
984985
this._findInput.setRegex(!!this._state.isRegex);
985986
this._findInput.setCaseSensitive(!!this._state.matchCase);
986987
this._findInput.setWholeWords(!!this._state.wholeWord);

src/vs/platform/history/browser/contextScopedHistoryWidget.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,9 +89,9 @@ export class ContextScopedHistoryInputBox extends HistoryInputBox {
8989
export class ContextScopedFindInput extends FindInput {
9090

9191
constructor(container: HTMLElement | null, contextViewProvider: IContextViewProvider, options: IFindInputOptions,
92-
@IContextKeyService contextKeyService: IContextKeyService, showFindOptions: boolean = false
92+
@IContextKeyService contextKeyService: IContextKeyService
9393
) {
94-
super(container, contextViewProvider, showFindOptions, options);
94+
super(container, contextViewProvider, options);
9595
this._register(registerAndCreateHistoryNavigationContext(contextKeyService, this.inputBox));
9696
}
9797
}

src/vs/workbench/contrib/codeEditor/browser/find/simpleFindWidget.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ const NLS_NEXT_MATCH_BTN_LABEL = nls.localize('label.nextMatchButton', "Next Mat
3232
const NLS_CLOSE_BTN_LABEL = nls.localize('label.closeButton', "Close");
3333

3434
interface IFindOptions {
35-
showOptionButtons?: boolean;
35+
showCommonFindToggles?: boolean;
3636
checkImeCompletionState?: boolean;
3737
showResultCount?: boolean;
3838
appendCaseSensitiveLabel?: string;
@@ -80,11 +80,12 @@ export abstract class SimpleFindWidget extends Widget {
8080
return { content: e.message };
8181
}
8282
},
83+
showCommonFindToggles: options.showCommonFindToggles,
8384
appendCaseSensitiveLabel: options.appendCaseSensitiveLabel && options.type === 'Terminal' ? this._getKeybinding(TerminalCommandId.ToggleFindCaseSensitive) : undefined,
8485
appendRegexLabel: options.appendRegexLabel && options.type === 'Terminal' ? this._getKeybinding(TerminalCommandId.ToggleFindRegex) : undefined,
8586
appendWholeWordsLabel: options.appendWholeWordsLabel && options.type === 'Terminal' ? this._getKeybinding(TerminalCommandId.ToggleFindWholeWord) : undefined,
8687
showHistoryHint: () => showHistoryKeybindingHint(_keybindingService)
87-
}, contextKeyService, options.showOptionButtons));
88+
}, contextKeyService));
8889
// Find History with update delayer
8990
this._updateHistoryDelayer = new Delayer<void>(500);
9091

src/vs/workbench/contrib/notebook/browser/contrib/find/notebookFindReplaceWidget.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -160,8 +160,11 @@ class NotebookFindInput extends FindInput {
160160
contextKeyService: IContextKeyService,
161161
readonly contextMenuService: IContextMenuService,
162162
readonly instantiationService: IInstantiationService,
163-
parent: HTMLElement | null, contextViewProvider: IContextViewProvider, showOptionButtons: boolean, options: IFindInputOptions) {
164-
super(parent, contextViewProvider, showOptionButtons, options);
163+
parent: HTMLElement | null,
164+
contextViewProvider: IContextViewProvider,
165+
options: IFindInputOptions
166+
) {
167+
super(parent, contextViewProvider, options);
165168

166169
this._register(registerAndCreateHistoryNavigationContext(contextKeyService, this.inputBox));
167170
this._filtersAction = new Action('notebookFindFilterAction', NOTEBOOK_FIND_FILTERS, 'notebook-filters ' + ThemeIcon.asClassName(filterIcon));
@@ -327,7 +330,6 @@ export abstract class SimpleFindReplaceWidget extends Widget {
327330
this.instantiationService,
328331
null,
329332
this._contextViewService,
330-
true,
331333
{
332334
label: NLS_FIND_INPUT_LABEL,
333335
placeholder: NLS_FIND_INPUT_PLACEHOLDER,
@@ -345,6 +347,7 @@ export abstract class SimpleFindReplaceWidget extends Widget {
345347
}
346348
},
347349
flexibleWidth: true,
350+
showCommonFindToggles: true
348351
}
349352
));
350353

src/vs/workbench/contrib/search/browser/searchWidget.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -314,11 +314,12 @@ export class SearchWidget extends Widget {
314314
history: options.searchHistory,
315315
showHistoryHint: () => showHistoryKeybindingHint(this.keybindingService),
316316
flexibleHeight: true,
317-
flexibleMaxHeight: SearchWidget.INPUT_MAX_HEIGHT
317+
flexibleMaxHeight: SearchWidget.INPUT_MAX_HEIGHT,
318+
showCommonFindToggles: true
318319
};
319320

320321
const searchInputContainer = dom.append(parent, dom.$('.search-container.input-box'));
321-
this.searchInput = this._register(new ContextScopedFindInput(searchInputContainer, this.contextViewService, inputOptions, this.contextKeyService, true));
322+
this.searchInput = this._register(new ContextScopedFindInput(searchInputContainer, this.contextViewService, inputOptions, this.contextKeyService));
322323
this._register(attachFindReplaceInputBoxStyler(this.searchInput, this.themeService));
323324
this.searchInput.onKeyDown((keyboardEvent: IKeyboardEvent) => this.onSearchInputKeyDown(keyboardEvent));
324325
this.searchInput.setValue(options.value || '');

src/vs/workbench/contrib/terminal/browser/terminalFindWidget.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ export class TerminalFindWidget extends SimpleFindWidget {
3131
@IThemeService private readonly _themeService: IThemeService,
3232
@IConfigurationService private readonly _configurationService: IConfigurationService
3333
) {
34-
super(findState, { showOptionButtons: true, showResultCount: true, type: 'Terminal' }, _contextViewService, _contextKeyService, keybindingService);
34+
super(findState, { showCommonFindToggles: true, showResultCount: true, type: 'Terminal' }, _contextViewService, _contextKeyService, keybindingService);
3535

3636
this._register(findState.onFindReplaceStateChange(() => {
3737
this.show();

src/vs/workbench/contrib/webview/browser/webviewFindWidget.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ export class WebviewFindWidget extends SimpleFindWidget {
3333
@IContextKeyService contextKeyService: IContextKeyService,
3434
@IKeybindingService keybindingService: IKeybindingService
3535
) {
36-
super(undefined, { showOptionButtons: false, checkImeCompletionState: _delegate.checkImeCompletionState }, contextViewService, contextKeyService, keybindingService);
36+
super(undefined, { showCommonFindToggles: false, checkImeCompletionState: _delegate.checkImeCompletionState }, contextViewService, contextKeyService, keybindingService);
3737
this._findWidgetFocused = KEYBINDING_CONTEXT_WEBVIEW_FIND_WIDGET_FOCUSED.bindTo(contextKeyService);
3838

3939
this._register(_delegate.hasFindResult(hasResult => {

0 commit comments

Comments
 (0)