From 4f0d1624b6f11458232708edb041223b20a5f9a3 Mon Sep 17 00:00:00 2001 From: d0wHc3r Date: Thu, 6 Aug 2020 20:51:28 +0200 Subject: [PATCH] fix: output line more than 3 digits When `String(line).length` is bigger than `3`, then calculation is negative and `repeat` will fail --- packages/shared/src/codeframe.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/shared/src/codeframe.ts b/packages/shared/src/codeframe.ts index 93cfa0718b1..a53323c7aeb 100644 --- a/packages/shared/src/codeframe.ts +++ b/packages/shared/src/codeframe.ts @@ -14,7 +14,7 @@ export function generateCodeFrame( for (let j = i - range; j <= i + range || end > count; j++) { if (j < 0 || j >= lines.length) continue const line = j + 1 - res.push(`${line}${' '.repeat(3 - String(line).length)}| ${lines[j]}`) + res.push(`${line}${' '.repeat(Math.abs(3 - String(line).length))}| ${lines[j]}`) const lineLength = lines[j].length if (j === i) { // push underline