diff --git a/blank.ts b/blank.ts index aea9091..1f8f62c 100644 --- a/blank.ts +++ b/blank.ts @@ -1144,7 +1144,10 @@ function substituteSelfClosingComponent( if (sourceLen < minLen) { return false; } - const inner = ' '.repeat(sourceLen - minLen); + // Keep the span's newlines inside the element, so later lines keep + // their line numbers. + const newlines = ctx.content.slice(elementStart, elementEnd).replace(/[^\r\n]/g, '').slice(0, sourceLen - minLen); + const inner = newlines + ' '.repeat(sourceLen - minLen - newlines.length); ctx.renames.push([elementStart, elementEnd, openTag + inner + closeTag]); ctx.fullyBlankedRanges.push([elementStart, elementEnd]); ctx.dynamicContentOffsets.push(elementStart); diff --git a/examples/multiline-self-closing-consumer.gts b/examples/multiline-self-closing-consumer.gts new file mode 100644 index 0000000..a132dde --- /dev/null +++ b/examples/multiline-self-closing-consumer.gts @@ -0,0 +1,14 @@ +// The self-closing call spans five lines. The untyped `