Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ripgrep pcre2 search support #19615

Merged
merged 1 commit into from Jul 1, 2019
Merged
Changes from all commits
Commits
File filter...
Filter file types
Jump to…
Jump to file or symbol
Failed to load files and symbols.

Always

Just for now

@@ -2652,6 +2652,30 @@ describe('Workspace', () => {
});
});
});
describe('pcre2 enabled', async () => {
it('supports lookbehind searches', async () => {
const results = [];

await scan(/(?<!a)aa\b/, { PCRE2: true }, result =>
results.push(result)
);

expect(results.length).toBe(1);
const { filePath, matches } = results[0];
expect(filePath).toBe(
atom.project.getDirectories()[0].resolve('a')
);
expect(matches).toHaveLength(1);
expect(matches[0]).toEqual({
matchText: 'aa',
lineText: 'cc aa cc',
lineTextOffset: 0,
range: [[1, 3], [1, 5]],
leadingContextLines: [],
trailingContextLines: []
});
});
});
}

it('returns results on lines with unicode strings', async () => {
@@ -269,6 +269,10 @@ module.exports = class RipgrepDirectorySearcher {
args.push('--no-ignore-vcs');
}

if (options.PCRE2) {
args.push('--pcre2');
}

args.push('.');

const child = spawn(this.rgPath, args, {
@@ -2104,6 +2104,7 @@ module.exports = class Workspace extends Model {
follow: this.config.get('core.followSymlinks'),
leadingContextLineCount: options.leadingContextLineCount || 0,
trailingContextLineCount: options.trailingContextLineCount || 0,
PCRE2: options.PCRE2,
didMatch: result => {
if (!this.project.isPathModified(result.filePath)) {
return iterator(result);
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.