提交 db0dd584 编写于 作者: B Benjamin Pasero

storage - be more "daten-sparsam"

上级 c1af5ff7
......@@ -33,7 +33,7 @@ import { IInstantiationService } from 'vs/platform/instantiation/common/instanti
import { TreeResourceNavigator, WorkbenchTree } from 'vs/platform/list/browser/listService';
import { INotificationService } from 'vs/platform/notification/common/notification';
import { IProgressService } from 'vs/platform/progress/common/progress';
import { IPatternInfo, IQueryOptions, ISearchComplete, ISearchConfiguration, ISearchHistoryService, ISearchProgressItem, ISearchQuery, VIEW_ID } from 'vs/platform/search/common/search';
import { IPatternInfo, IQueryOptions, ISearchComplete, ISearchConfiguration, ISearchHistoryService, ISearchProgressItem, ISearchQuery, VIEW_ID, ISearchHistoryValues } from 'vs/platform/search/common/search';
import { IStorageService, StorageScope } from 'vs/platform/storage/common/storage';
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
import { diffInserted, diffInsertedOutline, diffRemoved, diffRemovedOutline, editorFindMatchHighlight, editorFindMatchHighlightBorder, listActiveSelectionForeground } from 'vs/platform/theme/common/colorRegistry';
......@@ -1518,17 +1518,29 @@ export class SearchView extends Viewlet implements IViewlet, IPanel {
const isReplaceShown = this.searchAndReplaceWidget.isReplaceShown();
this.viewletState['view.showReplace'] = isReplaceShown;
const history: ISearchHistoryValues = Object.create(null);
const searchHistory = this.searchWidget.getSearchHistory();
if (searchHistory && searchHistory.length) {
history.search = searchHistory;
}
const replaceHistory = this.searchWidget.getReplaceHistory();
if (replaceHistory && replaceHistory.length) {
history.replace = replaceHistory;
}
const patternExcludesHistory = this.inputPatternExcludes.getHistory();
if (patternExcludesHistory && patternExcludesHistory.length) {
history.exclude = patternExcludesHistory;
}
const patternIncludesHistory = this.inputPatternIncludes.getHistory();
if (patternIncludesHistory && patternIncludesHistory.length) {
history.include = patternIncludesHistory;
}
this.searchHistoryService.save({
search: searchHistory,
replace: replaceHistory,
exclude: patternExcludesHistory,
include: patternIncludesHistory
});
this.searchHistoryService.save(history);
super.saveState();
}
......
......@@ -6,6 +6,7 @@
import { Emitter, Event } from 'vs/base/common/event';
import { ISearchHistoryValues, ISearchHistoryService } from 'vs/platform/search/common/search';
import { IStorageService, StorageScope } from 'vs/platform/storage/common/storage';
import { isEmptyObject } from 'vs/base/common/types';
export class SearchHistoryService implements ISearchHistoryService {
public _serviceBrand: any;
......@@ -40,6 +41,10 @@ export class SearchHistoryService implements ISearchHistoryService {
}
public save(history: ISearchHistoryValues): void {
this.storageService.store(SearchHistoryService.SEARCH_HISTORY_KEY, JSON.stringify(history), StorageScope.WORKSPACE);
if (isEmptyObject(history)) {
this.storageService.remove(SearchHistoryService.SEARCH_HISTORY_KEY, StorageScope.WORKSPACE);
} else {
this.storageService.store(SearchHistoryService.SEARCH_HISTORY_KEY, JSON.stringify(history), StorageScope.WORKSPACE);
}
}
}
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册