提交 1cbbd1d3 编写于 作者: R Ryan Stringham

Save search history when shutting down and load when starting up.

上级 8d666f34
......@@ -17,6 +17,10 @@ export class HistoryNavigator<T> implements INavigator<T> {
this._onChange();
}
public getHistory(): T[] {
return this._elements;
}
public add(t: T) {
this._history.add(t);
this._onChange();
......
......@@ -189,6 +189,14 @@ export class PatternInputWidget extends Widget {
return this.pattern.width();
}
public getHistory(): string[] {
return this.history.getHistory();
}
public setHistory(history: string[]) {
this.history = new HistoryNavigator<string>(history);
}
public showNextTerm() {
let next = this.history.next();
if (next) {
......
......@@ -180,9 +180,11 @@ export class SearchViewlet extends Viewlet {
const filePatterns = this.viewletSettings['query.filePatterns'] || '';
const patternExclusions = this.viewletSettings['query.folderExclusions'] || '';
const patternExclusionsHistory = this.viewletSettings['query.folderExclusionsHistory'] || [];
const exclusionsUsePattern = this.viewletSettings['query.exclusionsUsePattern'];
const includesUsePattern = this.viewletSettings['query.includesUsePattern'];
const patternIncludes = this.viewletSettings['query.folderIncludes'] || '';
const patternIncludesHistory = this.viewletSettings['query.folderIncludesHistory'] || [];
const queryDetailsExpanded = this.viewletSettings['query.queryDetailsExpanded'] || '';
const useIgnoreFiles = typeof this.viewletSettings['query.useIgnoreFiles'] === 'boolean' ?
this.viewletSettings['query.useIgnoreFiles'] :
......@@ -214,6 +216,7 @@ export class SearchViewlet extends Viewlet {
this.inputPatternIncludes.setIsGlobPattern(includesUsePattern);
this.inputPatternIncludes.setValue(patternIncludes);
this.inputPatternIncludes.setHistory(patternIncludesHistory);
this.inputPatternIncludes
.on(FindInput.OPTION_CHANGE, (e) => {
......@@ -237,6 +240,7 @@ export class SearchViewlet extends Viewlet {
this.inputPatternExclusions.setValue(patternExclusions);
this.inputPatternExclusions.setUseIgnoreFiles(useIgnoreFiles);
this.inputPatternExclusions.setUseExcludeSettings(useExcludeSettings);
this.inputPatternExclusions.setHistory(patternExclusionsHistory);
this.inputPatternExclusions
.on(FindInput.OPTION_CHANGE, (e) => {
......@@ -305,12 +309,14 @@ export class SearchViewlet extends Viewlet {
let isRegex = this.viewletSettings['query.regex'] === true;
let isWholeWords = this.viewletSettings['query.wholeWords'] === true;
let isCaseSensitive = this.viewletSettings['query.caseSensitive'] === true;
let searchHistory = this.viewletSettings['query.searchHistory'] || [];
this.searchWidget = this.instantiationService.createInstance(SearchWidget, builder, <ISearchWidgetOptions>{
value: contentPattern,
isRegex: isRegex,
isCaseSensitive: isCaseSensitive,
isWholeWords: isWholeWords
isWholeWords: isWholeWords,
history: searchHistory
});
if (this.storageService.getBoolean(SearchViewlet.SHOW_REPLACE_STORAGE_KEY, StorageScope.WORKSPACE, true)) {
......@@ -1368,23 +1374,28 @@ export class SearchViewlet extends Viewlet {
const isWholeWords = this.searchWidget.searchInput.getWholeWords();
const isCaseSensitive = this.searchWidget.searchInput.getCaseSensitive();
const contentPattern = this.searchWidget.searchInput.getValue();
const searchHistory = this.searchWidget.getHistory();
const patternExcludes = this.inputPatternExclusions.getValue().trim();
const patternExcludesHistory = this.inputPatternExclusions.getHistory();
const exclusionsUsePattern = this.inputPatternExclusions.isGlobPattern();
const patternIncludes = this.inputPatternIncludes.getValue().trim();
const patternIncludesHistory = this.inputPatternIncludes.getHistory();
const includesUsePattern = this.inputPatternIncludes.isGlobPattern();
const useIgnoreFiles = this.inputPatternExclusions.useIgnoreFiles();
// store memento
this.viewletSettings['query.contentPattern'] = contentPattern;
this.viewletSettings['query.searchHistory'] = searchHistory;
this.viewletSettings['query.regex'] = isRegex;
this.viewletSettings['query.wholeWords'] = isWholeWords;
this.viewletSettings['query.caseSensitive'] = isCaseSensitive;
this.viewletSettings['query.folderExclusions'] = patternExcludes;
this.viewletSettings['query.folderExclusionsHistory'] = patternExcludesHistory;
this.viewletSettings['query.exclusionsUsePattern'] = exclusionsUsePattern;
this.viewletSettings['query.folderIncludes'] = patternIncludes;
this.viewletSettings['query.folderIncludesHistory'] = patternIncludesHistory;
this.viewletSettings['query.includesUsePattern'] = includesUsePattern;
this.viewletSettings['query.useIgnoreFiles'] = useIgnoreFiles;
this.viewletSettings['query.contentPattern'] = contentPattern;
super.shutdown();
}
......
......@@ -35,6 +35,7 @@ export interface ISearchWidgetOptions {
isRegex?: boolean;
isCaseSensitive?: boolean;
isWholeWords?: boolean;
history?: string[];
}
class ReplaceAllAction extends Action {
......@@ -119,7 +120,7 @@ export class SearchWidget extends Widget {
@IKeybindingService private keyBindingService2: IKeybindingService,
) {
super();
this.searchHistory = new HistoryNavigator<string>();
this.searchHistory = new HistoryNavigator<string>(options.history);
this.replaceActive = Constants.ReplaceActiveKey.bindTo(this.keyBindingService);
this.searchInputBoxFocussed = Constants.SearchInputBoxFocussedKey.bindTo(this.keyBindingService);
this.replaceInputBoxFocussed = Constants.ReplaceInputBoxFocussedKey.bindTo(this.keyBindingService);
......@@ -170,6 +171,10 @@ export class SearchWidget extends Widget {
}
}
public getHistory(): string[] {
return this.searchHistory.getHistory();
}
public showNextSearchTerm() {
let next = this.searchHistory.next();
if (next) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册