]> git.ipfire.org Git - thirdparty/vuejs/core.git/commitdiff
fix: handle empty lines in codeframe
authorEvan You <yyx990803@gmail.com>
Thu, 14 Nov 2019 16:50:16 +0000 (11:50 -0500)
committerEvan You <yyx990803@gmail.com>
Thu, 14 Nov 2019 16:50:16 +0000 (11:50 -0500)
packages/shared/src/codeframe.ts

index 3ffb2808ac55ca09dd5426598e074e51fa8a28c8..890675432c7e6afc270272186e38176e5a7eed5b 100644 (file)
@@ -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) {