Commit 1f4206ed authored by Camil Staps's avatar Camil Staps 🐧

Cleanup mergeComments (frontend)

parent 8ada9db9
Pipeline #33960 passed with stages
in 25 minutes and 57 seconds
......@@ -140,27 +140,27 @@ function makeSummary(hidden) {
function mergeComments(code, comments) {
var maxLength = 0;
for (var i in code)
if ((i >= comments.length || (comments[i] != '' && comments[i].indexOf('\n')<0)) &&
for (var i=0; i<code.length; i++)
if (i < comments.length &&
comments[i] != '' &&
comments[i].indexOf('\n')<0 &&
code[i].length > maxLength)
maxLength = code[i].length;
var line=0;
for (var i=0; i<comments.length; i++) {
if (i < comments.length && comments[i] != '') {
console.log(comments[i].indexOf('\n'),comments[i]);
if (comments[i].indexOf('\n') < 0) {
code[line] = (code[line] + Array(maxLength + 1).join(' '))
.substring(0, maxLength+1) + '//* ' + comments[i];
line++;
code[line] = code[line] +
Array(maxLength+1-code[line].length).join(' ') +
' //* ' + comments[i];
} else {
comments[i]=comments[i].split('\n');
code.splice(line+1, 0, ...comments[i].map((c) => '\t\t//* ' + c));
line+=comments[i].length+1;
line+=comments[i].length;
}
} else {
line++;
}
line++;
}
return code;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment