From 1b4efacde097c78df1f06ee315fb767a50340dc2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johan=20R=C3=B8ed?= Date: Tue, 15 Sep 2026 17:10:28 +0200 Subject: [PATCH] Keep line numbers after a multi-line self-closing component A self-closing call that becomes a non-void element was written as one line over the source span. This removed the newlines of the span, so errors on later lines reported line numbers that were too low. --- blank.ts | 5 ++++- examples/multiline-self-closing-consumer.gts | 14 ++++++++++++++ test/glint-fixtures/info-popover-leaf.gts | 17 +++++++++++++++++ test/integration.test.ts | 13 +++++++++++++ 4 files changed, 48 insertions(+), 1 deletion(-) create mode 100644 examples/multiline-self-closing-consumer.gts create mode 100644 test/glint-fixtures/info-popover-leaf.gts 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 `