diff --git a/scripts/test.sh b/scripts/test.sh index 0812c9345fdf788e798725a7951b3006ec147484..ce1e5e11856a63c4822c3749fba592f7a7b77410 100755 --- a/scripts/test.sh +++ b/scripts/test.sh @@ -28,6 +28,7 @@ test -d node_modules || ./scripts/npm.sh install (test -f "$CODE" && [ $INTENDED_VERSION == $INSTALLED_VERSION ]) || ./node_modules/.bin/gulp electron # Unit Tests +export ELECTRON_ENABLE_LOGGING=1 if [[ "$OSTYPE" == "darwin"* ]]; then cd $ROOT ; ulimit -n 4096 ; \ "$CODE" \ diff --git a/src/vs/workbench/services/search/node/fileSearch.ts b/src/vs/workbench/services/search/node/fileSearch.ts index 064f8db2254b34f38de6ec5c35ed47e0c0183a01..c621b8b2c48cb4197003bebedfbb940275eadf2d 100644 --- a/src/vs/workbench/services/search/node/fileSearch.ts +++ b/src/vs/workbench/services/search/node/fileSearch.ts @@ -221,6 +221,7 @@ export class FileWalker { const useRipgrep = this.useRipgrep; let cmd: childProcess.ChildProcess; let noSiblingsClauses: boolean; + let filePatternSeen = false; if (useRipgrep) { const ripgrep = spawnRipgrepCmd(folderQuery, this.config.includePattern, this.folderExcludePatterns.get(folderQuery.folder).expression); cmd = ripgrep.cmd; @@ -262,11 +263,28 @@ export class FileWalker { if (useRipgrep && noSiblingsClauses) { for (const relativePath of relativeFiles) { + if (relativePath === this.filePattern) { + filePatternSeen = true; + } const basename = path.basename(relativePath); this.matchFile(onResult, { base: rootFolder, relativePath, basename }); } if (last) { - done(); + if (!filePatternSeen) { + this.checkFilePatternRelativeMatch(folderQuery.folder, (match, size) => { + if (match) { + this.resultCount++; + onResult({ + base: folderQuery.folder, + relativePath: this.filePattern, + basename: path.basename(this.filePattern), + }); + } + done(); + }); + } else { + done(); + } } return; } diff --git a/src/vs/workbench/services/search/test/node/search.test.ts b/src/vs/workbench/services/search/test/node/search.test.ts index 60ae0750d3f64111e5d1abb48dd9fc17bde075c0..75fddf759ba53d3e964a1dec4a2373ee475f828c 100644 --- a/src/vs/workbench/services/search/test/node/search.test.ts +++ b/src/vs/workbench/services/search/test/node/search.test.ts @@ -368,27 +368,27 @@ suite('FileSearchEngine', () => { }); }); - // test('Files: relative path to file ignores excludes', function (done: () => void) { - // let engine = new FileSearchEngine({ - // folderQueries: ROOT_FOLDER_QUERY, - // filePattern: path.normalize(path.join('examples', 'company.js')), - // excludePattern: { '**/*.js': true } - // }); - - // let count = 0; - // let res: IRawFileMatch; - // engine.search((result) => { - // if (result) { - // count++; - // } - // res = result; - // }, () => { }, (error) => { - // assert.ok(!error); - // assert.equal(count, 1); - // assert.equal(path.basename(res.relativePath), 'company.js'); - // done(); - // }); - // }); + test('Files: relative path to file ignores excludes', function (done: () => void) { + let engine = new FileSearchEngine({ + folderQueries: ROOT_FOLDER_QUERY, + filePattern: path.normalize(path.join('examples', 'company.js')), + excludePattern: { '**/*.js': true } + }); + + let count = 0; + let res: IRawFileMatch; + engine.search((result) => { + if (result) { + count++; + } + res = result; + }, () => { }, (error) => { + assert.ok(!error); + assert.equal(count, 1); + assert.equal(path.basename(res.relativePath), 'company.js'); + done(); + }); + }); test('Files: Include pattern, single files', function (done: () => void) { let engine = new FileSearchEngine({