From: Evan You Date: Thu, 14 Nov 2019 16:50:16 +0000 (-0500) Subject: fix: handle empty lines in codeframe X-Git-Tag: v3.0.0-alpha.0~198 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=4b2610c46820007f26b7bbce962180483bd6444e;p=thirdparty%2Fvuejs%2Fcore.git fix: handle empty lines in codeframe --- diff --git a/packages/shared/src/codeframe.ts b/packages/shared/src/codeframe.ts index 3ffb2808ac..890675432c 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) {