Handle case where token map extends beyond last line of input (fixes #166).

This commit is contained in:
David Anson 2019-02-13 19:52:34 -08:00
parent 90bd0810e7
commit 3e753636cf
2 changed files with 30 additions and 1 deletions

View file

@ -164,7 +164,7 @@ function annotateTokens(tokens, lines) {
token.line = lines[token.map[0]];
token.lineNumber = token.map[0] + 1;
// Trim bottom of token to exclude whitespace lines
while (token.map[1] && !(lines[token.map[1] - 1].trim())) {
while (token.map[1] && !((lines[token.map[1] - 1] || "").trim())) {
token.map[1]--;
}
// Annotate children with lineNumber