Skip to content

Commit

Permalink
Improve migrating from split include/exclude inputs to the new merged…
Browse files Browse the repository at this point in the history
… one
  • Loading branch information
roblourens committed Mar 14, 2018
1 parent 4c8fae3 commit 22f49f8
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/vs/workbench/parts/search/browser/searchView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand Down Expand Up @@ -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'] || '';
Expand Down Expand Up @@ -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);
Expand Down

1 comment on commit 22f49f8

@Abhijay
Copy link

@Abhijay Abhijay commented on 22f49f8 Mar 20, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With the new merged include exclude, how am I supposed to search for exclusive data types while ignoring certain folders?

e.g.

include: *.js
exclude: /someFolderWithUnrelatedFiles/*

Please sign in to comment.