diff --git a/src/vs/workbench/parts/search/browser/searchViewlet.ts b/src/vs/workbench/parts/search/browser/searchViewlet.ts index 0fb5ea6df3cb7d60c2805d09092706ac9aeaa6db..d4a9d901450e2f82820a02502768980e45d6fc40 100644 --- a/src/vs/workbench/parts/search/browser/searchViewlet.ts +++ b/src/vs/workbench/parts/search/browser/searchViewlet.ts @@ -315,6 +315,10 @@ export class SearchViewlet extends Viewlet { } private replaceAll(): void { + if (this.viewModel.count() === 0) { + return; + } + let progressRunner= this.progressService.show(100); let occurrences= this.viewModel.count(); @@ -325,7 +329,7 @@ export class SearchViewlet extends Viewlet { let confirmation= { title: nls.localize('replaceAll.confirmation.title', "Replace All"), - message: replaceValue ? nls.localize('replaceAll.confirmation.message', "Replace {0} occurrences with '{1}' across {2} files?", occurrences, replaceValue, fileCount) + message: replaceValue ? nls.localize('replaceAll.confirmation.message', "Replace {0} occurrences across {1} files with '{2}'?", occurrences, fileCount, replaceValue) : nls.localize('removeAll.confirmation.message', "Remove {0} occurrences across {1} files?", occurrences, fileCount), primaryButton: nls.localize('replaceAll.confirm.button', "Replace") }; @@ -811,6 +815,7 @@ export class SearchViewlet extends Viewlet { } doneTimer.stop(); + this.searchWidget.setReplaceAllActionState(this.viewModel.count() > 0); }; let onError = (e: any) => { diff --git a/src/vs/workbench/parts/search/browser/searchWidget.ts b/src/vs/workbench/parts/search/browser/searchWidget.ts index 4470ce5b9cf0360b135c92e96dda6b03fb417d77..9749013c3feafb4336f38bb3c21706fed202d27f 100644 --- a/src/vs/workbench/parts/search/browser/searchWidget.ts +++ b/src/vs/workbench/parts/search/browser/searchWidget.ts @@ -34,7 +34,6 @@ export class SearchWidget extends Widget { public domNode: HTMLElement; public searchInput: FindInput; private replaceInput: InputBox; - private searchSubmitted: boolean= false; private replaceInputContainer: HTMLElement; private toggleReplaceButton: Button; @@ -91,9 +90,9 @@ export class SearchWidget extends Widget { } public clear() { - this.searchSubmitted= false; this.searchInput.clear(); this.replaceInput.value= ''; + this.setReplaceAllActionState(false); } public isReplaceActive(): boolean { @@ -163,7 +162,6 @@ export class SearchWidget extends Widget { this.onkeyup(this.replaceInput.inputElement, (keyboardEvent) => this.onReplaceInputKeyUp(keyboardEvent)); this.replaceInput.onDidChange(() => this._onReplaceValueChanged.fire()); this.searchInput.inputBox.onDidChange(() => this.onSearchInputChanged()); - this.onSearchSubmit(() => this.updateReplaceActionState()); } private onToggleReplaceButton():void { @@ -171,12 +169,7 @@ export class SearchWidget extends Widget { dom.toggleClass(this.toggleReplaceButton.getElement(), 'collapse'); dom.toggleClass(this.toggleReplaceButton.getElement(), 'expand'); this._onReplaceToggled.fire(); - this.updateReplaceActionState(); - } - - private updateReplaceActionState():void { - let enabled= this.isReplaceShown() && this.searchSubmitted; - this.setReplaceAllActionState(enabled); + this._onReplaceState.fire(); } private validatSearchInput(value: string): any { @@ -198,8 +191,7 @@ export class SearchWidget extends Widget { } private onSearchInputChanged(): void { - this.searchSubmitted= false; - this.updateReplaceActionState(); + this.setReplaceAllActionState(false); } private onSearchInputKeyUp(keyboardEvent: IKeyboardEvent) { @@ -259,7 +251,6 @@ export class SearchWidget extends Widget { private submitSearch(refresh: boolean= true): void { if (this.searchInput.getValue()) { - this.searchSubmitted= true; this._onSearchSubmit.fire(refresh); } }