diff --git a/spec/workspace-spec.js b/spec/workspace-spec.js index 5af18e3cc..9ffdb05b2 100644 --- a/spec/workspace-spec.js +++ b/spec/workspace-spec.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 = []; diff --git a/src/ripgrep-directory-searcher.js b/src/ripgrep-directory-searcher.js index f538f6d17..63ce5cc24 100644 --- a/src/ripgrep-directory-searcher.js +++ b/src/ripgrep-directory-searcher.js @@ -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(); }