Skip to content
This repository has been archived by the owner on Dec 4, 2018. It is now read-only.

Commit

Permalink
Merge pull request #139 from TEHEK/lino-fix
Browse files Browse the repository at this point in the history
Fix: fixing line numbers
  • Loading branch information
nzakas committed Nov 26, 2015
2 parents b393828 + 5459a6a commit 3dbbfd6
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
13 changes: 8 additions & 5 deletions lib/doctrine.js
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,6 @@
while (last < length) {
ch = source.charCodeAt(last);
if (esutils.code.isLineTerminator(ch) && !(ch === 0x0D /* '\r' */ && source.charCodeAt(last + 1) === 0x0A /* '\n' */)) {
lineNumber += 1;
waiting = true;
} else if (waiting) {
if (ch === 0x40 /* '@' */) {
Expand Down Expand Up @@ -709,13 +708,11 @@
}
}

// Seek global index to end of this tag.
index = this._last;
return this._tag;
};

function parseTag(options) {
var title, parser;
var title, parser, tag;

// skip to tag
if (!skipToTag()) {
Expand All @@ -727,7 +724,13 @@

// construct tag parser
parser = new TagParser(options, title);
return parser.parse();
tag = parser.parse();

// Seek global index to end of this tag.
while (index < parser._last) {
advance();
}
return tag;
}

//
Expand Down
4 changes: 3 additions & 1 deletion test/parse.js
Original file line number Diff line number Diff line change
Expand Up @@ -1947,6 +1947,7 @@ describe('optional params', function() {
var res = doctrine.parse(
[
"/**",
" * @constructor",
" * @param {string} foo",
" * @returns {string}",
" *",
Expand All @@ -1959,7 +1960,8 @@ describe('optional params', function() {

res.tags[0].should.have.property('lineNumber', 1);
res.tags[1].should.have.property('lineNumber', 2);
res.tags[2].should.have.property('lineNumber', 4);
res.tags[2].should.have.property('lineNumber', 3);
res.tags[3].should.have.property('lineNumber', 5);
});

it('should handle \\r\\n line endings correctly', function() {
Expand Down

0 comments on commit 3dbbfd6

Please sign in to comment.