Fix #61041
This commit is contained in:
parent
9b739ad670
commit
d47f6b4f99
3 changed files with 46 additions and 26 deletions
|
@ -7,7 +7,6 @@ import * as path from 'path';
|
||||||
import * as arrays from 'vs/base/common/arrays';
|
import * as arrays from 'vs/base/common/arrays';
|
||||||
import { CancelablePromise, createCancelablePromise } from 'vs/base/common/async';
|
import { CancelablePromise, createCancelablePromise } from 'vs/base/common/async';
|
||||||
import { CancellationToken, CancellationTokenSource } from 'vs/base/common/cancellation';
|
import { CancellationToken, CancellationTokenSource } from 'vs/base/common/cancellation';
|
||||||
import { toErrorMessage } from 'vs/base/common/errorMessage';
|
|
||||||
import { canceled } from 'vs/base/common/errors';
|
import { canceled } from 'vs/base/common/errors';
|
||||||
import * as glob from 'vs/base/common/glob';
|
import * as glob from 'vs/base/common/glob';
|
||||||
import * as resources from 'vs/base/common/resources';
|
import * as resources from 'vs/base/common/resources';
|
||||||
|
@ -17,9 +16,9 @@ import { URI } from 'vs/base/common/uri';
|
||||||
import { TPromise } from 'vs/base/common/winjs.base';
|
import { TPromise } from 'vs/base/common/winjs.base';
|
||||||
import { compareItemsByScore, IItemAccessor, prepareQuery, ScorerCache } from 'vs/base/parts/quickopen/common/quickOpenScorer';
|
import { compareItemsByScore, IItemAccessor, prepareQuery, ScorerCache } from 'vs/base/parts/quickopen/common/quickOpenScorer';
|
||||||
import { ICachedSearchStats, IFileIndexProviderStats, IFileMatch, IFileSearchStats, IFolderQuery, IRawSearchQuery, ISearchCompleteStats, ISearchQuery } from 'vs/platform/search/common/search';
|
import { ICachedSearchStats, IFileIndexProviderStats, IFileMatch, IFileSearchStats, IFolderQuery, IRawSearchQuery, ISearchCompleteStats, ISearchQuery } from 'vs/platform/search/common/search';
|
||||||
|
import { IDirectoryEntry, IDirectoryTree, IInternalFileMatch } from 'vs/workbench/services/search/node/fileSearchManager';
|
||||||
|
import { QueryGlobTester, resolvePatternsForProvider } from 'vs/workbench/services/search/node/search';
|
||||||
import * as vscode from 'vscode';
|
import * as vscode from 'vscode';
|
||||||
import { resolvePatternsForProvider, QueryGlobTester } from 'vs/workbench/services/search/node/search';
|
|
||||||
import { IInternalFileMatch, IDirectoryTree, IDirectoryEntry } from 'vs/workbench/services/search/node/fileSearchManager';
|
|
||||||
|
|
||||||
interface IInternalSearchComplete<T = IFileSearchStats> {
|
interface IInternalSearchComplete<T = IFileSearchStats> {
|
||||||
limitHit: boolean;
|
limitHit: boolean;
|
||||||
|
@ -67,10 +66,6 @@ export class FileIndexSearchEngine {
|
||||||
}
|
}
|
||||||
|
|
||||||
public search(_onResult: (match: IInternalFileMatch) => void): TPromise<{ isLimitHit: boolean, stats: IFileIndexProviderStats }> {
|
public search(_onResult: (match: IInternalFileMatch) => void): TPromise<{ isLimitHit: boolean, stats: IFileIndexProviderStats }> {
|
||||||
if (this.config.folderQueries.length !== 1) {
|
|
||||||
throw new Error('Searches just one folder');
|
|
||||||
}
|
|
||||||
|
|
||||||
// Searches a single folder
|
// Searches a single folder
|
||||||
const folderQuery = this.config.folderQueries[0];
|
const folderQuery = this.config.folderQueries[0];
|
||||||
|
|
||||||
|
@ -99,15 +94,25 @@ export class FileIndexSearchEngine {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.searchInFolder(folderQuery, _onResult)
|
return Promise.all(this.config.folderQueries.map(fq => this.searchInFolder(folderQuery, onResult))).then(stats => {
|
||||||
.then(stats => {
|
resolve({
|
||||||
resolve({
|
isLimitHit: this.isLimitHit,
|
||||||
isLimitHit: this.isLimitHit,
|
stats: {
|
||||||
stats
|
directoriesWalked: this.dirsWalked,
|
||||||
});
|
filesWalked: this.filesWalked,
|
||||||
}, (err: Error) => {
|
fileWalkTime: stats.map(s => s.fileWalkTime).reduce((s, c) => s + c, 0),
|
||||||
reject(new Error(toErrorMessage(err)));
|
providerTime: stats.map(s => s.providerTime).reduce((s, c) => s + c, 0),
|
||||||
|
providerResultCount: stats.map(s => s.providerResultCount).reduce((s, c) => s + c, 0)
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
}, (errs: Error[]) => {
|
||||||
|
if (!Array.isArray(errs)) {
|
||||||
|
errs = [errs];
|
||||||
|
}
|
||||||
|
|
||||||
|
errs = errs.filter(e => !!e);
|
||||||
|
return TPromise.wrapError(errs[0]);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -86,7 +86,7 @@ export class QueryBuilder {
|
||||||
|
|
||||||
const query: ISearchQuery = {
|
const query: ISearchQuery = {
|
||||||
type,
|
type,
|
||||||
folderQueries,
|
folderQueries: folderQueries || [],
|
||||||
usingSearchPaths: !!(searchPaths && searchPaths.length),
|
usingSearchPaths: !!(searchPaths && searchPaths.length),
|
||||||
extraFileResources: options.extraFileResources,
|
extraFileResources: options.extraFileResources,
|
||||||
filePattern: options.filePattern
|
filePattern: options.filePattern
|
||||||
|
|
|
@ -9,7 +9,7 @@ import { CancellationToken } from 'vs/base/common/cancellation';
|
||||||
import { canceled } from 'vs/base/common/errors';
|
import { canceled } from 'vs/base/common/errors';
|
||||||
import { Event } from 'vs/base/common/event';
|
import { Event } from 'vs/base/common/event';
|
||||||
import { Disposable, IDisposable, toDisposable } from 'vs/base/common/lifecycle';
|
import { Disposable, IDisposable, toDisposable } from 'vs/base/common/lifecycle';
|
||||||
import { ResourceMap, values } from 'vs/base/common/map';
|
import { ResourceMap, values, keys } from 'vs/base/common/map';
|
||||||
import { Schemas } from 'vs/base/common/network';
|
import { Schemas } from 'vs/base/common/network';
|
||||||
import * as objects from 'vs/base/common/objects';
|
import * as objects from 'vs/base/common/objects';
|
||||||
import { StopWatch } from 'vs/base/common/stopwatch';
|
import { StopWatch } from 'vs/base/common/stopwatch';
|
||||||
|
@ -215,24 +215,26 @@ export class SearchService extends Disposable implements ISearchService {
|
||||||
const diskSearchQueries: IFolderQuery[] = [];
|
const diskSearchQueries: IFolderQuery[] = [];
|
||||||
const searchPs: TPromise<ISearchComplete>[] = [];
|
const searchPs: TPromise<ISearchComplete>[] = [];
|
||||||
|
|
||||||
query.folderQueries.forEach(fq => {
|
const fqs = this.groupFolderQueriesByScheme(query);
|
||||||
|
keys(fqs).forEach(scheme => {
|
||||||
|
const schemeFQs = fqs.get(scheme);
|
||||||
let provider = query.type === QueryType.File ?
|
let provider = query.type === QueryType.File ?
|
||||||
this.fileSearchProviders.get(fq.folder.scheme) || this.fileIndexProviders.get(fq.folder.scheme) :
|
this.fileSearchProviders.get(scheme) || this.fileIndexProviders.get(scheme) :
|
||||||
this.textSearchProviders.get(fq.folder.scheme);
|
this.textSearchProviders.get(scheme);
|
||||||
|
|
||||||
if (!provider && fq.folder.scheme === 'file') {
|
if (!provider && scheme === 'file') {
|
||||||
diskSearchQueries.push(fq);
|
diskSearchQueries.push(...schemeFQs);
|
||||||
} else if (!provider) {
|
} else if (!provider) {
|
||||||
throw new Error('No search provider registered for scheme: ' + fq.folder.scheme);
|
throw new Error('No search provider registered for scheme: ' + scheme);
|
||||||
} else {
|
} else {
|
||||||
const oneFolderQuery = {
|
const oneSchemeQuery = {
|
||||||
...query,
|
...query,
|
||||||
...{
|
...{
|
||||||
folderQueries: [fq]
|
folderQueries: schemeFQs
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
searchPs.push(provider.search(oneFolderQuery, onProviderProgress, token));
|
searchPs.push(provider.search(oneSchemeQuery, onProviderProgress, token));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -260,6 +262,19 @@ export class SearchService extends Disposable implements ISearchService {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private groupFolderQueriesByScheme(query: ISearchQuery): Map<string, IFolderQuery[]> {
|
||||||
|
const queries = new Map<string, IFolderQuery[]>();
|
||||||
|
|
||||||
|
query.folderQueries.forEach(fq => {
|
||||||
|
const schemeFQs = queries.get(fq.folder.scheme) || [];
|
||||||
|
schemeFQs.push(fq);
|
||||||
|
|
||||||
|
queries.set(fq.folder.scheme, schemeFQs);
|
||||||
|
});
|
||||||
|
|
||||||
|
return queries;
|
||||||
|
}
|
||||||
|
|
||||||
private sendTelemetry(query: ISearchQuery, endToEndTime: number, complete: ISearchComplete): void {
|
private sendTelemetry(query: ISearchQuery, endToEndTime: number, complete: ISearchComplete): void {
|
||||||
const fileSchemeOnly = query.folderQueries.every(fq => fq.folder.scheme === 'file');
|
const fileSchemeOnly = query.folderQueries.every(fq => fq.folder.scheme === 'file');
|
||||||
const otherSchemeOnly = query.folderQueries.every(fq => fq.folder.scheme !== 'file');
|
const otherSchemeOnly = query.folderQueries.every(fq => fq.folder.scheme !== 'file');
|
||||||
|
|
Loading…
Reference in a new issue