mirror of https://github.com/atom/atom.git
Merge pull request #19615 from dwelle/ripgrep-pcre2
Add ripgrep pcre2 search support
This commit is contained in:
commit
9ae30a3545
|
@ -2680,6 +2680,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);
|
||||
|
|
Loading…
Reference in New Issue