提交 a0af20d6 编写于 作者: A Alec Chan

Issue #62952: Disabled clear button only when all fields are cleared and...

Issue #62952: Disabled clear button only when all fields are cleared and enabled clear button after any input in search form.
上级 c95cd6ca
......@@ -520,9 +520,13 @@ export class HistoryInputBox extends InputBox implements IHistoryNavigationWidge
private readonly history: HistoryNavigator<string>;
private readonly _onInput = this._register(new Emitter<void>());
public readonly onInput: Event<void> = this._onInput.event;
constructor(container: HTMLElement, contextViewProvider: IContextViewProvider, options: IHistoryInputOptions) {
super(container, contextViewProvider, options);
this.history = new HistoryNavigator<string>(options.history, 100);
this.oninput(this.inputElement, (e) => this._onInput.fire());
}
public addToHistory(): void {
......
......@@ -41,6 +41,9 @@ export class PatternInputWidget extends Widget {
private _onSubmit = this._register(new Emitter<boolean>());
public onSubmit: CommonEvent<boolean> = this._onSubmit.event;
private readonly _onInput = this._register(new Emitter<void>());
public readonly onInput: CommonEvent<void> = this._onInput.event;
private _onCancel = this._register(new Emitter<boolean>());
public onCancel: CommonEvent<boolean> = this._onCancel.event;
......@@ -58,6 +61,8 @@ export class PatternInputWidget extends Widget {
this.render(options);
this.oninput(this.inputBox.inputElement, (e) => this._onInput.fire());
parent.appendChild(this.domNode);
}
......
......@@ -317,7 +317,7 @@ export class ClearSearchResultsAction extends Action {
update(): void {
const searchView = getSearchView(this.viewletService, this.panelService);
this.enabled = searchView && searchView.isSearchSubmitted();
this.enabled = searchView && !searchView.allSearchFieldsClear();//searchView.isSearchSubmitted();
}
public run(): Thenable<void> {
......
......@@ -161,6 +161,7 @@ export class SearchView extends Viewlet implements IViewlet, IPanel {
(() => this.selectCurrentMatch()));
this.delayedRefresh = this._register(new Delayer<void>(250));
}
private onDidChangeWorkbenchState(): void {
......@@ -271,6 +272,11 @@ export class SearchView extends Viewlet implements IViewlet, IPanel {
this._register(this.viewModel.searchResult.onChange((event) => this.onSearchResultsChanged(event)));
this._register(this.searchWidget.searchInput.onInput(() => this.updateActions()));
this._register(this.searchWidget.replaceInput.onInput(() => this.updateActions()));
this._register(this.searchIncludePattern.onInput(() => this.updateActions()));
this._register(this.searchExcludePattern.onInput(() => this.updateActions()));
this._register(this.onDidFocus(() => this.viewletFocused.set(true)));
this._register(this.onDidBlur(() => this.viewletFocused.set(false)));
}
......@@ -341,6 +347,7 @@ export class SearchView extends Viewlet implements IViewlet, IPanel {
}));
this._register(this.searchWidget.onReplaceAll(() => this.replaceAll()));
this.trackInputBox(this.searchWidget.searchInputFocusTracker);
this.trackInputBox(this.searchWidget.replaceInputFocusTracker);
}
......@@ -826,6 +833,13 @@ export class SearchView extends Viewlet implements IViewlet, IPanel {
return this.searching;
}
public allSearchFieldsClear(): boolean {
return this.searchWidget.getReplaceValue() === '' &&
this.searchWidget.searchInput.getValue() === '' &&
this.searchIncludePattern.getValue() === '' &&
this.searchExcludePattern.getValue() === '';
}
public hasSearchResults(): boolean {
return !this.viewModel.searchResult.isEmpty();
}
......@@ -837,7 +851,10 @@ export class SearchView extends Viewlet implements IViewlet, IPanel {
this.showSearchWithoutFolderMessage();
}
this.searchWidget.clear();
this.searchIncludePattern.setValue('');
this.searchExcludePattern.setValue('');
this.viewModel.cancelSearch();
this.updateActions();
}
public cancelSearch(): boolean {
......
......@@ -89,7 +89,7 @@ export class SearchWidget extends Widget {
private searchInputBoxFocused: IContextKey<boolean>;
private replaceContainer: HTMLElement;
private replaceInput: HistoryInputBox;
public replaceInput: HistoryInputBox;
private toggleReplaceButton: Button;
private replaceAllAction: ReplaceAllAction;
private replaceActive: IContextKey<boolean>;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册