From 22f49f8c93dfca48f9e631966b71b84c44371209 Mon Sep 17 00:00:00 2001 From: Rob Lourens Date: Wed, 14 Mar 2018 15:03:05 -0700 Subject: [PATCH] Improve migrating from split include/exclude inputs to the new merged one --- src/vs/workbench/parts/search/browser/searchView.ts | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/vs/workbench/parts/search/browser/searchView.ts b/src/vs/workbench/parts/search/browser/searchView.ts index 1b54934ef992b..7a1f6428a67ca 100644 --- a/src/vs/workbench/parts/search/browser/searchView.ts +++ b/src/vs/workbench/parts/search/browser/searchView.ts @@ -62,6 +62,7 @@ import { IPanel } from 'vs/workbench/common/panel'; import { IViewlet } from 'vs/workbench/common/viewlet'; import { Viewlet } from 'vs/workbench/browser/viewlet'; import { IPartService } from 'vs/workbench/services/part/common/partService'; +import { splitGlobAware } from 'vs/base/common/glob'; export class SearchView extends Viewlet implements IViewlet, IPanel { @@ -174,7 +175,8 @@ export class SearchView extends Viewlet implements IViewlet, IPanel { this.createSearchWidget(this.searchWidgetsContainer); const filePatterns = this.viewletSettings['query.filePatterns'] || ''; - const patternExclusions = this.viewletSettings['query.folderExclusions'] || ''; + const patternExclusions = this.viewletSettings['query.folderExclusions'] || 'foo, bar/**/*.js'; + delete this.viewletSettings['query.folderExclusions']; // Migrating from versions that have dedicated exclusions persisted const patternIncludes = this.viewletSettings['query.folderIncludes'] || ''; const patternIncludesHistory = this.viewletSettings['query.folderIncludesHistory'] || []; const queryDetailsExpanded = this.viewletSettings['query.queryDetailsExpanded'] || ''; @@ -205,14 +207,18 @@ export class SearchView extends Viewlet implements IViewlet, IPanel { placeholder: nls.localize('searchIncludeExclude.placeholder', "Examples: src, !*.ts, test/**/*.log") }); - + // For migrating from versions that have dedicated exclusions persisted let mergedIncludeExcludes = patternIncludes; if (patternExclusions) { if (mergedIncludeExcludes) { mergedIncludeExcludes += ', '; } - mergedIncludeExcludes += patternExclusions; + mergedIncludeExcludes += splitGlobAware(patternExclusions, ',') + .map(s => s.trim()) + .filter(s => !!s.length) + .map(s => '!' + s) + .join(', '); } this.inputPatternIncludes.setValue(mergedIncludeExcludes);