Refresh master with initial release/0.24 snapshot (#332)

* Initial port of release/0.24 source code

* Fix additional headers

* Fix a typo in launch.json
This commit is contained in:
Karl Burtram
2017-12-15 15:38:57 -08:00
committed by GitHub
parent 271b3a0b82
commit 6ad0df0e3e
7118 changed files with 107999 additions and 56466 deletions

View File

@@ -0,0 +1,63 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the Source EULA. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import * as cp from 'child_process';
import { rgPath } from 'vscode-ripgrep';
import { isMacintosh as isMac } from 'vs/base/common/platform';
import * as glob from 'vs/base/common/glob';
import { normalizeNFD, startsWith } from 'vs/base/common/strings';
import { IFolderSearch, IRawSearch } from './search';
import { foldersToIncludeGlobs, foldersToRgExcludeGlobs } from './ripgrepTextSearch';
export function spawnRipgrepCmd(config: IRawSearch, folderQuery: IFolderSearch, includePattern: glob.IExpression, excludePattern: glob.IExpression) {
const rgArgs = getRgArgs(config, folderQuery, includePattern, excludePattern);
return {
cmd: cp.spawn(rgPath, rgArgs.globArgs, { cwd: folderQuery.folder }),
siblingClauses: rgArgs.siblingClauses
};
}
function getRgArgs(config: IRawSearch, folderQuery: IFolderSearch, includePattern: glob.IExpression, excludePattern: glob.IExpression) {
const args = ['--files', '--hidden', '--case-sensitive'];
// includePattern can't have siblingClauses
foldersToIncludeGlobs([folderQuery], includePattern, false).forEach(globArg => {
args.push('-g', anchor(isMac ? normalizeNFD(globArg) : globArg));
});
let siblingClauses: glob.IExpression;
const rgGlobs = foldersToRgExcludeGlobs([folderQuery], excludePattern, undefined, false);
rgGlobs.globArgs
.forEach(rgGlob => args.push('-g', `!${anchor(isMac ? normalizeNFD(rgGlob) : rgGlob)}`));
siblingClauses = rgGlobs.siblingClauses;
if (folderQuery.disregardIgnoreFiles !== false) {
// Don't use .gitignore or .ignore
args.push('--no-ignore');
}
// Follow symlinks
if (!config.ignoreSymlinks) {
args.push('--follow');
}
if (config.exists) {
args.push('--quiet');
}
// Folder to search
args.push('--');
args.push('.');
return { globArgs: args, siblingClauses };
}
function anchor(glob: string) {
return startsWith(glob, '**') || startsWith(glob, '/') ? glob : `/${glob}`;
}