Update filter when programmatically changing quick input value

This commit is contained in:
Benjamin Pasero 2021-11-25 09:54:55 +01:00
parent 1e473b624f
commit ca07441587
No known key found for this signature in database
GPG key ID: E6380CC4C8219E65

View file

@ -487,9 +487,19 @@ class QuickPick<T extends IQuickPickItem> extends QuickInput implements IQuickPi
}
set value(value: string) {
this.doSetValue(value);
}
private doSetValue(value: string, skipUpdate?: boolean): void {
if (this._value !== value) {
this._value = value || '';
this.update();
this._value = value;
if (!skipUpdate) {
this.update();
}
const didFilter = this.ui.list.filter(this.filterValue(this._value));
if (didFilter) {
this.trySelectFirst();
}
this.onDidChangeValueEmitter.fire(this._value);
}
}
@ -734,15 +744,7 @@ class QuickPick<T extends IQuickPickItem> extends QuickInput implements IQuickPi
if (!this.visible) {
this.visibleDisposables.add(
this.ui.inputBox.onDidChange(value => {
if (value === this.value) {
return;
}
this._value = value;
const didFilter = this.ui.list.filter(this.filterValue(this.ui.inputBox.value));
if (didFilter) {
this.trySelectFirst();
}
this.onDidChangeValueEmitter.fire(value);
this.doSetValue(value, true /* skip update since this originates from the UI */);
}));
this.visibleDisposables.add(this.ui.inputBox.onMouseDown(event => {
if (!this.autoFocusOnList) {