Skip to content

Commit

Permalink
Merge pull request #158609 from microsoft/tyriar/156179-options
Browse files Browse the repository at this point in the history
Move showOptionButtons into IFindInputOptions.showCommonFindToggles
  • Loading branch information
Tyriar committed Aug 30, 2022
2 parents db4f5a8 + 9034897 commit dff9f59
Show file tree
Hide file tree
Showing 10 changed files with 29 additions and 19 deletions.
11 changes: 7 additions & 4 deletions src/vs/base/browser/ui/findinput/findInput.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export interface IFindInputOptions extends IFindInputStyles {
readonly flexibleWidth?: boolean;
readonly flexibleMaxHeight?: number;

readonly showCommonFindToggles?: boolean;
readonly appendCaseSensitiveLabel?: string;
readonly appendWholeWordsLabel?: string;
readonly appendRegexLabel?: string;
Expand All @@ -51,6 +52,7 @@ export class FindInput extends Widget {
private placeholder: string;
private validation?: IInputValidator;
private label: string;
private showCommonFindToggles: boolean;
private fixFocusOnOptionClickEnabled = true;
private imeSessionInProgress = false;
private additionalTogglesDisposables: DisposableStore = new DisposableStore();
Expand Down Expand Up @@ -101,11 +103,12 @@ export class FindInput extends Widget {
private _onRegexKeyDown = this._register(new Emitter<IKeyboardEvent>());
public readonly onRegexKeyDown: Event<IKeyboardEvent> = this._onRegexKeyDown.event;

constructor(parent: HTMLElement | null, contextViewProvider: IContextViewProvider | undefined, private readonly _showOptionButtons: boolean, options: IFindInputOptions) {
constructor(parent: HTMLElement | null, contextViewProvider: IContextViewProvider | undefined, options: IFindInputOptions) {
super();
this.placeholder = options.placeholder || '';
this.validation = options.validation;
this.label = options.label || NLS_DEFAULT_LABEL;
this.showCommonFindToggles = !!options.showCommonFindToggles;

this.inputActiveOptionBorder = options.inputActiveOptionBorder;
this.inputActiveOptionForeground = options.inputActiveOptionForeground;
Expand Down Expand Up @@ -243,12 +246,12 @@ export class FindInput extends Widget {

this.controls = document.createElement('div');
this.controls.className = 'controls';
this.controls.style.display = this._showOptionButtons ? 'block' : 'none';
this.controls.style.display = this.showCommonFindToggles ? 'block' : 'none';
this.controls.appendChild(this.caseSensitive.domNode);
this.controls.appendChild(this.wholeWords.domNode);
this.controls.appendChild(this.regex.domNode);

if (!this._showOptionButtons) {
if (!this.showCommonFindToggles) {
this.caseSensitive.domNode.style.display = 'none';
this.wholeWords.domNode.style.display = 'none';
this.regex.domNode.style.display = 'none';
Expand Down Expand Up @@ -345,7 +348,7 @@ export class FindInput extends Widget {
}

this.inputBox.paddingRight =
(this._showOptionButtons ? this.caseSensitive.width() + this.wholeWords.width() + this.regex.width() : 0)
(this.showCommonFindToggles ? this.caseSensitive.width() + this.wholeWords.width() + this.regex.width() : 0)
+ this.additionalToggles.reduce((r, t) => r + t.width(), 0);
}

Expand Down
5 changes: 3 additions & 2 deletions src/vs/base/browser/ui/tree/abstractTree.ts
Original file line number Diff line number Diff line change
Expand Up @@ -721,9 +721,10 @@ class FindWidget<T, TFilterData> extends Disposable {
this.modeToggle = this._register(new ModeToggle({ ...options, isChecked: mode === TreeFindMode.Filter }));
this.onDidChangeMode = Event.map(this.modeToggle.onChange, () => this.modeToggle.checked ? TreeFindMode.Filter : TreeFindMode.Highlight, this._store);

this.findInput = this._register(new FindInput(this.elements.findInput, contextViewProvider, false, {
this.findInput = this._register(new FindInput(this.elements.findInput, contextViewProvider, {
label: localize('type to search', "Type to search"),
additionalToggles: [this.modeToggle]
additionalToggles: [this.modeToggle],
showCommonFindToggles: false
}));

this.actionbar = this._register(new ActionBar(this.elements.actionbar));
Expand Down
2 changes: 1 addition & 1 deletion src/vs/base/parts/quickinput/browser/quickInputBox.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export class QuickInputBox extends Disposable {
) {
super();
this.container = dom.append(this.parent, $('.quick-input-box'));
this.findInput = this._register(new FindInput(this.container, undefined, false, { label: '' }));
this.findInput = this._register(new FindInput(this.container, undefined, { label: '' }));
}

onKeyDown = (handler: (event: StandardKeyboardEvent) => void): IDisposable => {
Expand Down
3 changes: 2 additions & 1 deletion src/vs/editor/contrib/find/browser/findWidget.ts
Original file line number Diff line number Diff line change
Expand Up @@ -979,8 +979,9 @@ export class FindWidget extends Widget implements IOverlayWidget, IVerticalSashL
flexibleHeight,
flexibleWidth,
flexibleMaxHeight: 118,
showCommonFindToggles: true,
showHistoryHint: () => showHistoryKeybindingHint(this._keybindingService)
}, this._contextKeyService, true));
}, this._contextKeyService));
this._findInput.setRegex(!!this._state.isRegex);
this._findInput.setCaseSensitive(!!this._state.matchCase);
this._findInput.setWholeWords(!!this._state.wholeWord);
Expand Down
4 changes: 2 additions & 2 deletions src/vs/platform/history/browser/contextScopedHistoryWidget.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,9 @@ export class ContextScopedHistoryInputBox extends HistoryInputBox {
export class ContextScopedFindInput extends FindInput {

constructor(container: HTMLElement | null, contextViewProvider: IContextViewProvider, options: IFindInputOptions,
@IContextKeyService contextKeyService: IContextKeyService, showFindOptions: boolean = false
@IContextKeyService contextKeyService: IContextKeyService
) {
super(container, contextViewProvider, showFindOptions, options);
super(container, contextViewProvider, options);
this._register(registerAndCreateHistoryNavigationContext(contextKeyService, this.inputBox));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ const NLS_NEXT_MATCH_BTN_LABEL = nls.localize('label.nextMatchButton', "Next Mat
const NLS_CLOSE_BTN_LABEL = nls.localize('label.closeButton', "Close");

interface IFindOptions {
showOptionButtons?: boolean;
showCommonFindToggles?: boolean;
checkImeCompletionState?: boolean;
showResultCount?: boolean;
appendCaseSensitiveLabel?: string;
Expand Down Expand Up @@ -80,11 +80,12 @@ export abstract class SimpleFindWidget extends Widget {
return { content: e.message };
}
},
showCommonFindToggles: options.showCommonFindToggles,
appendCaseSensitiveLabel: options.appendCaseSensitiveLabel && options.type === 'Terminal' ? this._getKeybinding(TerminalCommandId.ToggleFindCaseSensitive) : undefined,
appendRegexLabel: options.appendRegexLabel && options.type === 'Terminal' ? this._getKeybinding(TerminalCommandId.ToggleFindRegex) : undefined,
appendWholeWordsLabel: options.appendWholeWordsLabel && options.type === 'Terminal' ? this._getKeybinding(TerminalCommandId.ToggleFindWholeWord) : undefined,
showHistoryHint: () => showHistoryKeybindingHint(_keybindingService)
}, contextKeyService, options.showOptionButtons));
}, contextKeyService));
// Find History with update delayer
this._updateHistoryDelayer = new Delayer<void>(500);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,8 +160,11 @@ class NotebookFindInput extends FindInput {
contextKeyService: IContextKeyService,
readonly contextMenuService: IContextMenuService,
readonly instantiationService: IInstantiationService,
parent: HTMLElement | null, contextViewProvider: IContextViewProvider, showOptionButtons: boolean, options: IFindInputOptions) {
super(parent, contextViewProvider, showOptionButtons, options);
parent: HTMLElement | null,
contextViewProvider: IContextViewProvider,
options: IFindInputOptions
) {
super(parent, contextViewProvider, options);

this._register(registerAndCreateHistoryNavigationContext(contextKeyService, this.inputBox));
this._filtersAction = new Action('notebookFindFilterAction', NOTEBOOK_FIND_FILTERS, 'notebook-filters ' + ThemeIcon.asClassName(filterIcon));
Expand Down Expand Up @@ -327,7 +330,6 @@ export abstract class SimpleFindReplaceWidget extends Widget {
this.instantiationService,
null,
this._contextViewService,
true,
{
label: NLS_FIND_INPUT_LABEL,
placeholder: NLS_FIND_INPUT_PLACEHOLDER,
Expand All @@ -345,6 +347,7 @@ export abstract class SimpleFindReplaceWidget extends Widget {
}
},
flexibleWidth: true,
showCommonFindToggles: true
}
));

Expand Down
5 changes: 3 additions & 2 deletions src/vs/workbench/contrib/search/browser/searchWidget.ts
Original file line number Diff line number Diff line change
Expand Up @@ -314,11 +314,12 @@ export class SearchWidget extends Widget {
history: options.searchHistory,
showHistoryHint: () => showHistoryKeybindingHint(this.keybindingService),
flexibleHeight: true,
flexibleMaxHeight: SearchWidget.INPUT_MAX_HEIGHT
flexibleMaxHeight: SearchWidget.INPUT_MAX_HEIGHT,
showCommonFindToggles: true
};

const searchInputContainer = dom.append(parent, dom.$('.search-container.input-box'));
this.searchInput = this._register(new ContextScopedFindInput(searchInputContainer, this.contextViewService, inputOptions, this.contextKeyService, true));
this.searchInput = this._register(new ContextScopedFindInput(searchInputContainer, this.contextViewService, inputOptions, this.contextKeyService));
this._register(attachFindReplaceInputBoxStyler(this.searchInput, this.themeService));
this.searchInput.onKeyDown((keyboardEvent: IKeyboardEvent) => this.onSearchInputKeyDown(keyboardEvent));
this.searchInput.setValue(options.value || '');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export class TerminalFindWidget extends SimpleFindWidget {
@IThemeService private readonly _themeService: IThemeService,
@IConfigurationService private readonly _configurationService: IConfigurationService
) {
super(findState, { showOptionButtons: true, showResultCount: true, type: 'Terminal' }, _contextViewService, _contextKeyService, keybindingService);
super(findState, { showCommonFindToggles: true, showResultCount: true, type: 'Terminal' }, _contextViewService, _contextKeyService, keybindingService);

this._register(findState.onFindReplaceStateChange(() => {
this.show();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export class WebviewFindWidget extends SimpleFindWidget {
@IContextKeyService contextKeyService: IContextKeyService,
@IKeybindingService keybindingService: IKeybindingService
) {
super(undefined, { showOptionButtons: false, checkImeCompletionState: _delegate.checkImeCompletionState }, contextViewService, contextKeyService, keybindingService);
super(undefined, { showCommonFindToggles: false, checkImeCompletionState: _delegate.checkImeCompletionState }, contextViewService, contextKeyService, keybindingService);
this._findWidgetFocused = KEYBINDING_CONTEXT_WEBVIEW_FIND_WIDGET_FOCUSED.bindTo(contextKeyService);

this._register(_delegate.hasFindResult(hasResult => {
Expand Down

0 comments on commit dff9f59

Please sign in to comment.