Skip to content

Commit

Permalink
Merge pull request #21859 from delftswa2017/21600-clearing-search-res…
Browse files Browse the repository at this point in the history
…ults

proposal to fix issue 21600
  • Loading branch information
sandy081 authored Mar 7, 2017
2 parents e415a78 + a5b8769 commit 56c54ef
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
7 changes: 7 additions & 0 deletions src/vs/base/common/history.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@ export class HistoryNavigator<T> implements INavigator<T> {
this._onChange();
}

public addIfNotPresent(t: T) {
if (!this._history.contains(t)) {
this.add(t);
}
}

public next(): T {
if (this._navigator.next()) {
return this._navigator.current();
Expand Down Expand Up @@ -67,4 +73,5 @@ export class HistoryNavigator<T> implements INavigator<T> {
this._history = new ArraySet<T>(data.slice(data.length - this._limit));
}
}

}
8 changes: 7 additions & 1 deletion src/vs/workbench/parts/search/browser/searchWidget.ts
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,13 @@ export class SearchWidget extends Widget {
}

public showPreviousSearchTerm() {
let previous = this.searchHistory.previous();
let previous;
if (this.searchInput.getValue().length === 0) {
previous = this.searchHistory.current();
} else {
this.searchHistory.addIfNotPresent(this.searchInput.getValue());
previous = this.searchHistory.previous();
}
if (previous) {
this.searchInput.setValue(previous);
}
Expand Down

0 comments on commit 56c54ef

Please sign in to comment.