From 174b797e498f4c39457be7b9fff4f4f97f0dd987 Mon Sep 17 00:00:00 2001 From: Anas Shahid Date: Thu, 23 Jul 2020 11:48:53 -0400 Subject: [PATCH] [SIW]: Run search on input change Fixes: https://github.com/eclipse-theia/theia/issues/7346 Runs a search query only when there is a change in the input field Signed-off-by: Anas Shahid --- .../src/browser/search-in-workspace-widget.tsx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) 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 0b1655cbfc589..228f89af0818b 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 @@ -361,10 +361,13 @@ export class SearchInWorkspaceWidget extends BaseWidget implements StatefulWidge protected readonly search = (e: React.KeyboardEvent) => this.doSearch(e); protected doSearch(e: React.KeyboardEvent): void { if (e.target) { + const searchValue = (e.target as HTMLInputElement).value; if (Key.ARROW_DOWN.keyCode === e.keyCode) { this.resultTreeWidget.focusFirstResult(); + } else if (this.searchTerm === searchValue && Key.ENTER.keyCode !== e.keyCode) { + return; } else { - this.searchTerm = (e.target as HTMLInputElement).value; + this.searchTerm = searchValue; this.resultTreeWidget.search(this.searchTerm, (this.searchInWorkspaceOptions || {})); } }