Fixes the emit of comment when comment ends on last line

This fixes regression from 5a7500ca5e with addition of eof token
Handles #1714
This commit is contained in:
Sheetal Nandi
2015-01-20 12:24:13 -08:00
parent 7f749909da
commit e8e2356afa
7 changed files with 27 additions and 85 deletions

View File

@@ -170,9 +170,10 @@ module ts {
function writeCommentRange(currentSourceFile: SourceFile, writer: EmitTextWriter, comment: CommentRange, newLine: string){
if (currentSourceFile.text.charCodeAt(comment.pos + 1) === CharacterCodes.asterisk) {
var firstCommentLineAndCharacter = currentSourceFile.getLineAndCharacterFromPosition(comment.pos);
var lastLine = currentSourceFile.getLineStarts().length;
var firstCommentLineIndent: number;
for (var pos = comment.pos, currentLine = firstCommentLineAndCharacter.line; pos < comment.end; currentLine++) {
var nextLineStart = currentSourceFile.getPositionFromLineAndCharacter(currentLine + 1, /*character*/1);
var nextLineStart = currentLine === lastLine ? (comment.end + 1) : currentSourceFile.getPositionFromLineAndCharacter(currentLine + 1, /*character*/1);
if (pos !== comment.pos) {
// If we are not emitting first line, we need to write the spaces to adjust the alignment