From 4b2610c46820007f26b7bbce962180483bd6444e Mon Sep 17 00:00:00 2001 From: Evan You Date: Thu, 14 Nov 2019 11:50:16 -0500 Subject: [PATCH] fix: handle empty lines in codeframe --- packages/shared/src/codeframe.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/shared/src/codeframe.ts b/packages/shared/src/codeframe.ts index 3ffb2808a..890675432 100644 --- a/packages/shared/src/codeframe.ts +++ b/packages/shared/src/codeframe.ts @@ -20,7 +20,10 @@ export function generateCodeFrame( if (j === i) { // push underline const pad = start - (count - lineLength) + 1 - const length = end > count ? lineLength - pad : end - start + const length = Math.max( + 0, + end > count ? lineLength - pad : end - start + ) res.push(` | ` + ' '.repeat(pad) + '^'.repeat(length)) } else if (j > i) { if (end > count) {