From 30ee80b2d7a9f80b7122d21aa2cc8e274344345b Mon Sep 17 00:00:00 2001 From: Liang Zhou Date: Wed, 12 May 2021 21:22:53 -0500 Subject: [PATCH] Update lineMap after altering source.text Fixes #2680. --- packages/jsii/lib/transforms/ts-comment-replacer.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/jsii/lib/transforms/ts-comment-replacer.ts b/packages/jsii/lib/transforms/ts-comment-replacer.ts index 3d4dae885c..33a33af409 100644 --- a/packages/jsii/lib/transforms/ts-comment-replacer.ts +++ b/packages/jsii/lib/transforms/ts-comment-replacer.ts @@ -126,5 +126,8 @@ function whiteoutLeadingComments(node: ts.Node, source: ts.SourceFile) { text = text.slice(0, pos).padEnd(end, ' ') + text.slice(end); } }); - source.text = text; + if (source.text !== text) { + source.text = text; + (source as any).lineMap = (ts as any).computeLineStarts(text); + } }