Skip to content

Commit 4daffd7

Browse files
committed
use first lineno in case of line continuation instead of last
1 parent 042ac97 commit 4daffd7

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

inst/js/parser.js

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,7 @@ function parseLine(line, lineno, options) {
322322
if (line.match(lineContinuationRegex)) {
323323
// Line continues on next line.
324324
var remainder = line.replace(lineContinuationRegex, '', 'g');
325-
return { command: null, remainder: remainder };
325+
return { command: null, remainder: remainder, lineno: lineno };
326326
}
327327

328328
command = splitCommand(line);
@@ -371,16 +371,19 @@ function parse(contents, options) {
371371
var lineno;
372372
var lines = contents.split(/[\r?\n]/);
373373
var lookingForDirectives = true;
374+
// var newlines = 0;
374375
var parseOptions = {};
375376
var parseResult;
377+
var prevLineno;
376378
var regexMatch;
377379
var remainder = '';
378380
var includeComments = options && options['includeComments'];
379381

380382
for (i = 0; i < lines.length; i++) {
381-
lineno = i + 1;
383+
lineno = i + 1 //- newlines;
382384
if (remainder) {
383385
line = remainder + lines[i];
386+
lineno = prevLineno;
384387
} else {
385388
line = lines[i];
386389
}
@@ -413,8 +416,11 @@ function parse(contents, options) {
413416
if (parseResult.command.name !== 'COMMENT' || includeComments) {
414417
commands.push(parseResult.command);
415418
}
416-
}
419+
} //else if(parseResult.lineno) {
420+
// newlines++;
421+
// }
417422
remainder = parseResult.remainder;
423+
prevLineno = parseResult.lineno;
418424
}
419425

420426
return commands;

0 commit comments

Comments
 (0)