Skip to content
This repository was archived by the owner on Aug 7, 2023. It is now read-only.

Commit c75dde6

Browse files
committed
Don't split output
Let the regex do it's job of text processing and don't feed it only parts of the output.
1 parent 4963604 commit c75dde6

File tree

1 file changed

+8
-10
lines changed

1 file changed

+8
-10
lines changed

lib/main.js

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ export default {
2121
},
2222

2323
provideLinter() {
24-
const regex = /.+:(\d+):\s*(.+?)[,:]\s(.+)/;
24+
const regex = /.+:(\d+):\s*(.+?)[,:]\s(.+)/g;
2525
return {
2626
name: 'Ruby',
2727
grammarScopes: ['source.ruby', 'source.ruby.rails', 'source.ruby.rspec'],
@@ -42,19 +42,17 @@ export default {
4242
};
4343
const output = await helpers.exec(this.executablePath, execArgs, execOpts);
4444
const toReturn = [];
45-
output.split(/\r?\n/).forEach((line) => {
46-
const matches = regex.exec(line);
47-
if (matches === null) {
48-
return;
49-
}
50-
const msgLine = Number.parseInt(matches[1] - 1, 10);
45+
let match = regex.exec(output);
46+
while (match !== null) {
47+
const msgLine = Number.parseInt(match[1] - 1, 10);
5148
toReturn.push({
5249
range: helpers.rangeFromLineNumber(textEditor, msgLine),
53-
type: matches[2],
54-
text: matches[3],
50+
type: match[2],
51+
text: match[3],
5552
filePath,
5653
});
57-
});
54+
match = regex.exec(output);
55+
}
5856
return toReturn;
5957
},
6058
};

0 commit comments

Comments
 (0)