From d6b75ec94e3b2cb73671596f6725c073a135b80b Mon Sep 17 00:00:00 2001 From: Gabriel Bodeen Date: Fri, 19 Nov 2021 00:02:29 +0100 Subject: [PATCH] Add ctrl-shift-F searches to history Signed-off-by: Gabriel Bodeen --- .../browser/search-in-workspace-widget.tsx | 32 ++++++++++--------- 1 file changed, 17 insertions(+), 15 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 8979a935079a7..e4ae95c74f2b6 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 @@ -220,9 +220,9 @@ export class SearchInWorkspaceWidget extends BaseWidget implements StatefulWidge const values = Array.from(new Set(uris.map(uri => `${uri}/**`))); const value = values.join(', '); this.searchInWorkspaceOptions.include = values; - const include = document.getElementById('include-glob-field'); - if (include) { - (include as HTMLInputElement).value = value; + if (this.includeRef.current) { + this.includeRef.current.value = value; + this.includeRef.current.addToHistory(); } this.update(); } @@ -234,9 +234,9 @@ export class SearchInWorkspaceWidget extends BaseWidget implements StatefulWidge */ updateSearchTerm(term: string, showReplaceField?: boolean): void { this.searchTerm = term; - const search = document.getElementById('search-input-field'); - if (search) { - (search as HTMLInputElement).value = term; + if (this.searchRef.current) { + this.searchRef.current.value = term; + this.searchRef.current.addToHistory(); } if (showReplaceField) { this.showReplaceField = true; @@ -284,15 +284,17 @@ export class SearchInWorkspaceWidget extends BaseWidget implements StatefulWidge this.matchCaseState.enabled = false; this.wholeWordState.enabled = false; this.regExpState.enabled = false; - const search = document.getElementById('search-input-field'); - const replace = document.getElementById('replace-input-field'); - const include = document.getElementById('include-glob-field'); - const exclude = document.getElementById('exclude-glob-field'); - if (search && replace && include && exclude) { - (search as HTMLInputElement).value = ''; - (replace as HTMLInputElement).value = ''; - (include as HTMLInputElement).value = ''; - (exclude as HTMLInputElement).value = ''; + if (this.searchRef.current) { + this.searchRef.current.value = ''; + } + if (this.replaceRef.current) { + this.replaceRef.current.value = ''; + } + if (this.includeRef.current) { + this.includeRef.current.value = ''; + } + if (this.excludeRef.current) { + this.excludeRef.current.value = ''; } this.performSearch(); this.update();