From a821f30a4961913bd09fc5793bf2cf9114d525a6 Mon Sep 17 00:00:00 2001 From: Jan Bicker Date: Mon, 6 Aug 2018 10:00:10 +0000 Subject: [PATCH] Replace term gets updated on keyup now Fixes theia-ide/theia#2511 Signed-off-by: Jan Bicker --- .../browser/search-in-workspace-widget.tsx | 28 +++++++++---------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/packages/search-in-workspace/src/browser/search-in-workspace-widget.tsx b/packages/search-in-workspace/src/browser/search-in-workspace-widget.tsx index 75bc2397bc304..8e66f071f4a13 100644 --- a/packages/search-in-workspace/src/browser/search-in-workspace-widget.tsx +++ b/packages/search-in-workspace/src/browser/search-in-workspace-widget.tsx @@ -287,8 +287,8 @@ export class SearchInWorkspaceWidget extends BaseWidget implements StatefulWidge this.update(); } - protected readonly handleKeyUp = (e: React.KeyboardEvent) => this.doHandleKeyUp(e); - protected doHandleKeyUp(e: React.KeyboardEvent) { + protected readonly search = (e: React.KeyboardEvent) => this.doSearch(e); + protected doSearch(e: React.KeyboardEvent) { if (e.target) { if (Key.ARROW_DOWN.keyCode === e.keyCode) { this.resultTreeWidget.focusFirstResult(); @@ -307,7 +307,7 @@ export class SearchInWorkspaceWidget extends BaseWidget implements StatefulWidge size={1} placeholder='Search' defaultValue={this.searchTerm} - onKeyUp={this.handleKeyUp} + onKeyUp={this.search} >; const notification = this.renderNotification(); const optionContainer = this.renderOptionContainer(); @@ -322,6 +322,16 @@ export class SearchInWorkspaceWidget extends BaseWidget implements StatefulWidge ; } + protected readonly updateReplaceTerm = (e: React.KeyboardEvent) => this.doUpdateReplaceTerm(e); + protected doUpdateReplaceTerm(e: React.KeyboardEvent) { + if (e.target) { + this.replaceTerm = (e.target as HTMLInputElement).value; + this.resultTreeWidget.replaceTerm = this.replaceTerm; + this.resultTreeWidget.search(this.searchTerm, (this.searchInWorkspaceOptions || {})); + this.update(); + } + } + protected renderReplaceField(): React.ReactNode { const replaceAllButtonContainer = this.renderReplaceAllButtonContainer(); return
@@ -331,17 +341,7 @@ export class SearchInWorkspaceWidget extends BaseWidget implements StatefulWidge size={1} placeholder='Replace' defaultValue={this.replaceTerm} - onKeyUp={e => { - if (e.target) { - if (Key.ENTER.keyCode === e.keyCode) { - this.resultTreeWidget.search(this.searchTerm, (this.searchInWorkspaceOptions || {})); - this.update(); - } else { - this.replaceTerm = (e.target as HTMLInputElement).value; - this.resultTreeWidget.replaceTerm = this.replaceTerm; - } - } - }}> + onKeyUp={this.updateReplaceTerm}> {replaceAllButtonContainer}
;