mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-23 18:19:12 +01:00
Fix #53510 - remove relative pattern matching from file search
This commit is contained in:
@@ -13,7 +13,6 @@ import * as strings from 'vs/base/common/strings';
|
||||
import URI, { UriComponents } from 'vs/base/common/uri';
|
||||
import { PPromise, TPromise } from 'vs/base/common/winjs.base';
|
||||
import * as extfs from 'vs/base/node/extfs';
|
||||
import * as pfs from 'vs/base/node/pfs';
|
||||
import { IFileMatch, IFolderQuery, IPatternInfo, IRawSearchQuery, ISearchCompleteStats, ISearchQuery } from 'vs/platform/search/common/search';
|
||||
import * as vscode from 'vscode';
|
||||
import { ExtHostSearchShape, IMainContext, MainContext, MainThreadSearchShape } from './extHost.protocol';
|
||||
@@ -30,9 +29,9 @@ export class ExtHostSearch implements ExtHostSearchShape {
|
||||
|
||||
private _fileSearchManager: FileSearchManager;
|
||||
|
||||
constructor(mainContext: IMainContext, private _schemeTransformer: ISchemeTransformer, private _extfs = extfs, private _pfs = pfs) {
|
||||
constructor(mainContext: IMainContext, private _schemeTransformer: ISchemeTransformer, private _extfs = extfs) {
|
||||
this._proxy = mainContext.getProxy(MainContext.MainThreadSearch);
|
||||
this._fileSearchManager = new FileSearchManager(this._pfs);
|
||||
this._fileSearchManager = new FileSearchManager();
|
||||
}
|
||||
|
||||
private _transformScheme(scheme: string): string {
|
||||
@@ -518,7 +517,7 @@ class FileSearchEngine {
|
||||
|
||||
private globalExcludePattern: glob.ParsedExpression;
|
||||
|
||||
constructor(private config: ISearchQuery, private provider: vscode.SearchProvider, private _pfs: typeof pfs) {
|
||||
constructor(private config: ISearchQuery, private provider: vscode.SearchProvider) {
|
||||
this.filePattern = config.filePattern;
|
||||
this.includePattern = config.includePattern && glob.parse(config.includePattern);
|
||||
this.maxResults = config.maxResults || null;
|
||||
@@ -633,19 +632,6 @@ class FileSearchEngine {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (noSiblingsClauses && this.isLimitHit) {
|
||||
// If the limit was hit, check whether filePattern is an exact relative match because it must be included
|
||||
return this.checkFilePatternRelativeMatch(fq.folder).then(({ exists, size }) => {
|
||||
if (exists) {
|
||||
onResult({
|
||||
base: fq.folder,
|
||||
relativePath: this.filePattern,
|
||||
basename: path.basename(this.filePattern),
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
this.matchDirectoryTree(tree, queryTester, onResult);
|
||||
return null;
|
||||
}).then(
|
||||
@@ -743,24 +729,6 @@ class FileSearchEngine {
|
||||
matchDirectory(rootEntries);
|
||||
}
|
||||
|
||||
private checkFilePatternRelativeMatch(base: URI): TPromise<{ exists: boolean, size?: number }> {
|
||||
if (!this.filePattern || path.isAbsolute(this.filePattern) || base.scheme !== 'file') {
|
||||
return TPromise.wrap({ exists: false });
|
||||
}
|
||||
|
||||
const absolutePath = path.join(base.fsPath, this.filePattern);
|
||||
return this._pfs.stat(absolutePath).then(stat => {
|
||||
return {
|
||||
exists: !stat.isDirectory(),
|
||||
size: stat.size
|
||||
};
|
||||
}, err => {
|
||||
return {
|
||||
exists: false
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
private matchFile(onResult: (result: IInternalFileMatch) => void, candidate: IInternalFileMatch): void {
|
||||
if (this.isFilePatternMatch(candidate.relativePath) && (!this.includePattern || this.includePattern(candidate.relativePath, candidate.basename))) {
|
||||
if (this.exists || (this.maxResults && this.resultCount >= this.maxResults)) {
|
||||
@@ -800,12 +768,10 @@ class FileSearchManager {
|
||||
|
||||
private readonly expandedCacheKeys = new Map<string, string[]>();
|
||||
|
||||
constructor(private _pfs: typeof pfs) { }
|
||||
|
||||
fileSearch(config: ISearchQuery, provider: vscode.SearchProvider): PPromise<ISearchCompleteStats, IFileMatch[]> {
|
||||
let searchP: PPromise;
|
||||
return new PPromise<ISearchCompleteStats, IFileMatch[]>((c, e, p) => {
|
||||
const engine = new FileSearchEngine(config, provider, this._pfs);
|
||||
const engine = new FileSearchEngine(config, provider);
|
||||
|
||||
searchP = this.doSearch(engine, FileSearchManager.BATCH_SIZE).then(
|
||||
result => {
|
||||
|
||||
Reference in New Issue
Block a user