Skip to content

Commit

Permalink
GH-9150: Run SIW when updating the glob fields.
Browse files Browse the repository at this point in the history
Closes #9150.

Signed-off-by: Akos Kitta <kittaakos@typefox.io>
  • Loading branch information
Akos Kitta authored and kittaakos committed Mar 12, 2021
1 parent 45a008d commit 52d460f
Showing 1 changed file with 20 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -553,10 +553,27 @@ export class SearchInWorkspaceWidget extends BaseWidget implements StatefulWidge
id={kind + '-glob-field'}
onKeyUp={e => {
if (e.target) {
if (Key.ENTER.keyCode === KeyCode.createKeyCode(e.nativeEvent).key?.keyCode) {
const targetValue = (e.target as HTMLInputElement).value || '';
let shouldSearch = Key.ENTER.keyCode === KeyCode.createKeyCode(e.nativeEvent).key?.keyCode;
const currentOptions = (this.searchInWorkspaceOptions[kind] || []).slice().map(s => s.trim()).sort();
const candidateOptions = this.splitOnComma(targetValue).map(s => s.trim()).sort();
const sameAs = (left: string[], right: string[]) => {
if (left.length !== right.length) {
return false;
}
for (let i = 0; i < left.length; i++) {
if (left[i] !== right[i]) {
return false;
}
}
return true;
};
if (!sameAs(currentOptions, candidateOptions)) {
this.searchInWorkspaceOptions[kind] = this.splitOnComma(targetValue);
shouldSearch = true;
}
if (shouldSearch) {
this.resultTreeWidget.search(this.searchTerm, this.searchInWorkspaceOptions);
} else {
this.searchInWorkspaceOptions[kind] = this.splitOnComma((e.target as HTMLInputElement).value);
}
}
}}
Expand Down

0 comments on commit 52d460f

Please sign in to comment.