mirror of
https://github.com/atom/atom.git
synced 2026-04-28 03:01:47 -04:00
Merge pull request #19618 from atom/fix-empty-result
Fix issue when ripgrep returns matches that are empty
This commit is contained in:
@@ -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();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user