Skip to content
Permalink
Browse files

Merge pull request #19618 from atom/fix-empty-result

Fix issue when ripgrep returns matches that are empty
  • Loading branch information...
rafeca committed Jul 1, 2019
2 parents 401248d + 3d2d439 commit 3210eacdccd084bccba6ecaa06ea9509dd843f66
Showing with 29 additions and 1 deletion.
  1. +28 −0 spec/workspace-spec.js
  2. +1 −1 src/ripgrep-directory-searcher.js
@@ -2512,6 +2512,34 @@ describe('Workspace', () => {
});

if (ripgrep) {
it('returns empty text matches', async () => {
const results = [];
await scan(
/^\s{0}/,
{
paths: [`oh-git`]
},
result => results.push(result)
);

expect(results.length).toBe(1);
const { filePath, matches } = results[0];
expect(filePath).toBe(
atom.project
.getDirectories()[0]
.resolve(path.join('a-dir', 'oh-git'))
);
expect(matches).toHaveLength(1);
expect(matches[0]).toEqual({
matchText: '',
lineText: 'bbb aaaa',
lineTextOffset: 0,
range: [[0, 0], [0, 0]],
leadingContextLines: [],
trailingContextLines: []
});
});

describe('newlines on regexps', async () => {
it('returns multiline results from regexps', async () => {
const results = [];
@@ -157,7 +157,7 @@ function processSubmatch(submatch, lineText, offsetRow) {
}

function getText(input) {
return input.text
return 'text' in input
? input.text
: Buffer.from(input.bytes, 'base64').toString();
}

0 comments on commit 3210eac

Please sign in to comment.
You can’t perform that action at this time.