Skip to content

Commit d287d59

Browse files
authored
testing: persist empty history filter (microsoft#154573)
Fixes microsoft#150120
1 parent 1095364 commit d287d59

File tree

1 file changed

+9
-11
lines changed

1 file changed

+9
-11
lines changed

src/vs/workbench/contrib/testing/browser/testingExplorerFilter.ts

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ const testFilterDescriptions: { [K in TestFilterTerm]: string } = {
3535
export class TestingExplorerFilter extends BaseActionViewItem {
3636
private input!: SuggestEnabledInputWithHistory;
3737
private wrapper!: HTMLDivElement;
38-
private readonly history: StoredValue<string[]> = this.instantiationService.createInstance(StoredValue, {
38+
private readonly history: StoredValue<{ values: string[]; lastValue: string } | string[]> = this.instantiationService.createInstance(StoredValue, {
3939
key: 'testing.filterHistory2',
4040
scope: StorageScope.WORKSPACE,
4141
target: StorageTarget.USER
@@ -65,9 +65,12 @@ export class TestingExplorerFilter extends BaseActionViewItem {
6565
const wrapper = this.wrapper = dom.$('.testing-filter-wrapper');
6666
container.appendChild(wrapper);
6767

68-
const history = this.history.get([]);
69-
if (history.length) {
70-
this.state.setText(history[history.length - 1]);
68+
let history = this.history.get({ lastValue: '', values: [] });
69+
if (history instanceof Array) {
70+
history = { lastValue: '', values: history };
71+
}
72+
if (history.lastValue) {
73+
this.state.setText(history.lastValue);
7174
}
7275

7376
const input = this.input = this._register(this.instantiationService.createInstance(ContextScopedSuggestEnabledInputWithHistory, {
@@ -94,7 +97,7 @@ export class TestingExplorerFilter extends BaseActionViewItem {
9497
value: this.state.text.value,
9598
placeholderText: localize('testExplorerFilter', "Filter (e.g. text, !exclude, @tag)"),
9699
},
97-
history
100+
history: history.values
98101
}));
99102
this._register(attachSuggestEnabledInputBoxStyler(input, this.themeService));
100103

@@ -145,12 +148,7 @@ export class TestingExplorerFilter extends BaseActionViewItem {
145148
* Persists changes to the input history.
146149
*/
147150
public saveState() {
148-
const history = this.input.getHistory();
149-
if (history.length) {
150-
this.history.store(history);
151-
} else {
152-
this.history.delete();
153-
}
151+
this.history.store({ lastValue: this.input.getValue(), values: this.input.getHistory() });
154152
}
155153

156154
/**

0 commit comments

Comments
 (0)