From 3038f429da887ccbfa131a014a57a6fc7782c8bb Mon Sep 17 00:00:00 2001 From: Rob Lourens Date: Mon, 21 May 2018 10:28:16 -0700 Subject: [PATCH] Fix #50175 --- src/vs/workbench/api/node/extHostSearch.ts | 2 +- .../api/extHostSearch.test.ts | 29 +++++++++++++++++++ 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/src/vs/workbench/api/node/extHostSearch.ts b/src/vs/workbench/api/node/extHostSearch.ts index a8b0ba77f92..4c0370d20d8 100644 --- a/src/vs/workbench/api/node/extHostSearch.ts +++ b/src/vs/workbench/api/node/extHostSearch.ts @@ -349,7 +349,7 @@ class QueryGlobTester { } return this._parsedIncludeExpression ? - TPromise.as(this._parsedIncludeExpression(testPath, basename, siblingsFn)).then(result => !result) : + TPromise.as(this._parsedIncludeExpression(testPath, basename, siblingsFn)).then(result => !!result) : TPromise.wrap(true); }).then(included => { return included; diff --git a/src/vs/workbench/test/electron-browser/api/extHostSearch.test.ts b/src/vs/workbench/test/electron-browser/api/extHostSearch.test.ts index 588f3e88e61..2bc337d218f 100644 --- a/src/vs/workbench/test/electron-browser/api/extHostSearch.test.ts +++ b/src/vs/workbench/test/electron-browser/api/extHostSearch.test.ts @@ -959,6 +959,35 @@ suite('ExtHostSearch', () => { makeTextResult('file3.js')]); }); + test('include pattern applied', async () => { + const providedResults: vscode.TextSearchResult[] = [ + makeTextResult('file1.js'), + makeTextResult('file1.ts') + ]; + + await registerTestSearchProvider({ + provideTextSearchResults(query: vscode.TextSearchQuery, options: vscode.TextSearchOptions, progress: vscode.Progress, token: vscode.CancellationToken): Thenable { + providedResults.forEach(r => progress.report(r)); + return TPromise.wrap(null); + } + }); + + const query: ISearchQuery = { + type: QueryType.Text, + + includePattern: { + '*.ts': true + }, + + folderQueries: [ + { folder: rootFolderA } + ] + }; + + const results = await runTextSearch(getPattern('foo'), query); + assertResults(results, providedResults.slice(1)); + }); + test('max results = 1', async () => { const providedResults: vscode.TextSearchResult[] = [ makeTextResult('file1.ts'),