mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-12 19:18:32 -05:00
Merge from vscode 64980ea1f3f532c82bb6c28d27bba9ef2c5b4463 (#7206)
* Merge from vscode 64980ea1f3f532c82bb6c28d27bba9ef2c5b4463 * fix config changes * fix strictnull checks
This commit is contained in:
@@ -43,20 +43,20 @@ process.on('exit', () => {
|
||||
export class FileWalker {
|
||||
private config: IFileQuery;
|
||||
private filePattern: string;
|
||||
private normalizedFilePatternLowercase: string;
|
||||
private normalizedFilePatternLowercase: string | null = null;
|
||||
private includePattern: glob.ParsedExpression | undefined;
|
||||
private maxResults: number | null;
|
||||
private exists: boolean;
|
||||
private maxFilesize: number | null;
|
||||
private maxFilesize: number | null = null;
|
||||
private isLimitHit: boolean;
|
||||
private resultCount: number;
|
||||
private isCanceled: boolean;
|
||||
private fileWalkSW: StopWatch;
|
||||
private isCanceled = false;
|
||||
private fileWalkSW: StopWatch | null = null;
|
||||
private directoriesWalked: number;
|
||||
private filesWalked: number;
|
||||
private errors: string[];
|
||||
private cmdSW: StopWatch;
|
||||
private cmdResultCount: number;
|
||||
private cmdSW: StopWatch | null = null;
|
||||
private cmdResultCount: number = 0;
|
||||
|
||||
private folderExcludePatterns: Map<string, AbsoluteAndRelativeParsedExpression>;
|
||||
private globalExcludePattern: glob.ParsedExpression | undefined;
|
||||
@@ -139,8 +139,8 @@ export class FileWalker {
|
||||
rootFolderDone(null, undefined);
|
||||
}
|
||||
});
|
||||
}, (errors, result) => {
|
||||
this.fileWalkSW.stop();
|
||||
}, (errors, _result) => {
|
||||
this.fileWalkSW!.stop();
|
||||
const err = errors ? arrays.coalesce(errors)[0] : null;
|
||||
done(err, this.isLimitHit);
|
||||
});
|
||||
@@ -455,8 +455,8 @@ export class FileWalker {
|
||||
|
||||
getStats(): ISearchEngineStats {
|
||||
return {
|
||||
cmdTime: this.cmdSW && this.cmdSW.elapsed(),
|
||||
fileWalkTime: this.fileWalkSW.elapsed(),
|
||||
cmdTime: this.cmdSW!.elapsed(),
|
||||
fileWalkTime: this.fileWalkSW!.elapsed(),
|
||||
directoriesWalked: this.directoriesWalked,
|
||||
filesWalked: this.filesWalked,
|
||||
cmdResultCount: this.cmdResultCount
|
||||
@@ -578,7 +578,9 @@ export class FileWalker {
|
||||
return true; // support the all-matching wildcard
|
||||
}
|
||||
|
||||
return strings.fuzzyContains(path, this.normalizedFilePatternLowercase);
|
||||
if (this.normalizedFilePatternLowercase) {
|
||||
return strings.fuzzyContains(path, this.normalizedFilePatternLowercase);
|
||||
}
|
||||
}
|
||||
|
||||
// No patterns means we match all
|
||||
|
||||
@@ -254,7 +254,7 @@ export class SearchService implements IRawSearchService {
|
||||
const query = prepareQuery(config.filePattern || '');
|
||||
const compare = (matchA: IRawFileMatch, matchB: IRawFileMatch) => compareItemsByScore(matchA, matchB, query, true, FileMatchItemAccessor, scorerCache);
|
||||
|
||||
const maxResults = config.maxResults || Number.MAX_VALUE;
|
||||
const maxResults = typeof config.maxResults === 'number' ? config.maxResults : Number.MAX_VALUE;
|
||||
return arrays.topAsync(results, compare, maxResults, 10000, token);
|
||||
}
|
||||
|
||||
|
||||
@@ -394,13 +394,11 @@ function getRgArgs(query: TextSearchQuery, options: TextSearchOptions): string[]
|
||||
args.push('--encoding', options.encoding);
|
||||
}
|
||||
|
||||
let pattern = query.pattern;
|
||||
|
||||
// Ripgrep handles -- as a -- arg separator. Only --.
|
||||
// - is ok, --- is ok, --some-flag is also ok. Need to special case.
|
||||
if (pattern === '--') {
|
||||
if (query.pattern === '--') {
|
||||
query.isRegExp = true;
|
||||
pattern = '\\-\\-';
|
||||
query.pattern = '\\-\\-';
|
||||
}
|
||||
|
||||
if (query.isMultiline && !query.isRegExp) {
|
||||
@@ -413,7 +411,7 @@ function getRgArgs(query: TextSearchQuery, options: TextSearchOptions): string[]
|
||||
}
|
||||
|
||||
if (query.isRegExp) {
|
||||
pattern = unicodeEscapesToPCRE2(pattern);
|
||||
query.pattern = unicodeEscapesToPCRE2(query.pattern);
|
||||
}
|
||||
|
||||
// Allow $ to match /r/n
|
||||
@@ -421,7 +419,7 @@ function getRgArgs(query: TextSearchQuery, options: TextSearchOptions): string[]
|
||||
|
||||
let searchPatternAfterDoubleDashes: Maybe<string>;
|
||||
if (query.isWordMatch) {
|
||||
const regexp = createRegExp(pattern, !!query.isRegExp, { wholeWord: query.isWordMatch });
|
||||
const regexp = createRegExp(query.pattern, !!query.isRegExp, { wholeWord: query.isWordMatch });
|
||||
const regexpStr = regexp.source.replace(/\\\//g, '/'); // RegExp.source arbitrarily returns escaped slashes. Search and destroy.
|
||||
args.push('--regexp', regexpStr);
|
||||
} else if (query.isRegExp) {
|
||||
@@ -430,7 +428,7 @@ function getRgArgs(query: TextSearchQuery, options: TextSearchOptions): string[]
|
||||
args.push('--regexp', fixedRegexpQuery);
|
||||
args.push('--auto-hybrid-regex');
|
||||
} else {
|
||||
searchPatternAfterDoubleDashes = pattern;
|
||||
searchPatternAfterDoubleDashes = query.pattern;
|
||||
args.push('--fixed-strings');
|
||||
}
|
||||
|
||||
@@ -479,11 +477,18 @@ export function spreadGlobComponents(globArg: string): string[] {
|
||||
}
|
||||
|
||||
export function unicodeEscapesToPCRE2(pattern: string): string {
|
||||
const reg = /((?:[^\\]|^)(?:\\\\)*)\\u([a-z0-9]{4})(?!\d)/g;
|
||||
// Replace an unescaped $ at the end of the pattern with \r?$
|
||||
// Match $ preceeded by none or even number of literal \
|
||||
while (pattern.match(reg)) {
|
||||
pattern = pattern.replace(reg, `$1\\x{$2}`);
|
||||
// Match \u1234
|
||||
const unicodePattern = /((?:[^\\]|^)(?:\\\\)*)\\u([a-z0-9]{4})/g;
|
||||
|
||||
while (pattern.match(unicodePattern)) {
|
||||
pattern = pattern.replace(unicodePattern, `$1\\x{$2}`);
|
||||
}
|
||||
|
||||
// Match \u{1234}
|
||||
// \u with 5-6 characters will be left alone because \x only takes 4 characters.
|
||||
const unicodePatternWithBraces = /((?:[^\\]|^)(?:\\\\)*)\\u\{([a-z0-9]{4})\}/g;
|
||||
while (pattern.match(unicodePatternWithBraces)) {
|
||||
pattern = pattern.replace(unicodePatternWithBraces, `$1\\x{$2}`);
|
||||
}
|
||||
|
||||
return pattern;
|
||||
|
||||
@@ -7,8 +7,8 @@ import * as path from 'vs/base/common/path';
|
||||
import { mapArrayOrNot } from 'vs/base/common/arrays';
|
||||
import { CancellationToken, CancellationTokenSource } from 'vs/base/common/cancellation';
|
||||
import { toErrorMessage } from 'vs/base/common/errorMessage';
|
||||
import * as glob from 'vs/base/common/glob';
|
||||
import * as resources from 'vs/base/common/resources';
|
||||
import * as glob from 'vs/base/common/glob';
|
||||
import { URI } from 'vs/base/common/uri';
|
||||
import { toCanonicalName } from 'vs/base/node/encoding';
|
||||
import * as pfs from 'vs/base/node/pfs';
|
||||
@@ -17,9 +17,9 @@ import { TextSearchProvider, TextSearchResult, TextSearchMatch, TextSearchComple
|
||||
|
||||
export class TextSearchManager {
|
||||
|
||||
private collector: TextSearchResultsCollector;
|
||||
private collector: TextSearchResultsCollector | null = null;
|
||||
|
||||
private isLimitHit: boolean;
|
||||
private isLimitHit = false;
|
||||
private resultCount = 0;
|
||||
|
||||
constructor(private query: ITextQuery, private provider: TextSearchProvider, private _pfs: typeof pfs = pfs) {
|
||||
@@ -52,7 +52,7 @@ export class TextSearchManager {
|
||||
const newResultSize = this.resultSize(result);
|
||||
this.resultCount += newResultSize;
|
||||
if (newResultSize > 0) {
|
||||
this.collector.add(result, folderIdx);
|
||||
this.collector!.add(result, folderIdx);
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -62,7 +62,7 @@ export class TextSearchManager {
|
||||
return this.searchInFolder(fq, r => onResult(r, i), tokenSource.token);
|
||||
})).then(results => {
|
||||
tokenSource.dispose();
|
||||
this.collector.flush();
|
||||
this.collector!.flush();
|
||||
|
||||
const someFolderHitLImit = results.some(result => !!result && !!result.limitHit);
|
||||
resolve({
|
||||
@@ -198,8 +198,8 @@ function patternInfoToQuery(patternInfo: IPatternInfo): TextSearchQuery {
|
||||
export class TextSearchResultsCollector {
|
||||
private _batchedCollector: BatchedCollector<IFileMatch>;
|
||||
|
||||
private _currentFolderIdx: number;
|
||||
private _currentUri: URI;
|
||||
private _currentFolderIdx: number = -1;
|
||||
private _currentUri: URI | undefined;
|
||||
private _currentFileMatch: IFileMatch | null = null;
|
||||
|
||||
constructor(private _onResult: (result: IFileMatch[]) => void) {
|
||||
|
||||
Reference in New Issue
Block a user