Skip to content

Commit

Permalink
[file-search] fix #4599: don't mess around with given include patterns
Browse files Browse the repository at this point in the history
Signed-off-by: Anton Kosyakov <[email protected]>
  • Loading branch information
akosyakov committed Apr 3, 2019
1 parent 23fd73a commit a0b7396
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -89,16 +89,16 @@ describe('search-service', function () {
expect(matches.length).to.eq(1);
});

it('should support file searches with globs without the prefixed or trailing star (*)', async () => {
it('should NOT support file searches with globs without the prefixed or trailing star (*)', async () => {
const rootUri = FileUri.create(path.resolve(__dirname, '../../test-resources/subdir1/sub2')).toString();

const trailingMatches = await service.find('', { rootUris: [rootUri], includePatterns: ['*oo'] });
expect(trailingMatches).to.be.not.undefined;
expect(trailingMatches.length).to.eq(1);
expect(trailingMatches.length).to.eq(0);

const prefixedMatches = await service.find('', { rootUris: [rootUri], includePatterns: ['oo*'] });
expect(prefixedMatches).to.be.not.undefined;
expect(prefixedMatches.length).to.eq(1);
expect(prefixedMatches.length).to.eq(0);
});
});

Expand Down
9 changes: 1 addition & 8 deletions packages/file-search/src/node/file-search-service-impl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,14 +110,7 @@ export class FileSearchServiceImpl implements FileSearchService {
const args = ['--files', '--case-sensitive'];
if (options.includePatterns) {
for (const includePattern of options.includePatterns) {
let includeGlob = includePattern;
if (!includeGlob.endsWith('*')) {
includeGlob = `${includeGlob}*`;
}
if (!includeGlob.startsWith('*')) {
includeGlob = `*${includeGlob}`;
}
args.push('--glob', includeGlob);
args.push('--glob', includePattern);
}
}
if (!options.useGitIgnore) {
Expand Down

0 comments on commit a0b7396

Please sign in to comment.