From 3af6a1b401a574c78695dbf7fe39152bca1e304b Mon Sep 17 00:00:00 2001 From: Harry Porter-Mills Date: Thu, 30 Jun 2022 17:45:17 -0400 Subject: [PATCH] fix: prevent crash when the pad amount is negative (#8747) --- packages/vite/src/node/utils.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/vite/src/node/utils.ts b/packages/vite/src/node/utils.ts index 345ce0a8627365..6f7bef05752003 100644 --- a/packages/vite/src/node/utils.ts +++ b/packages/vite/src/node/utils.ts @@ -480,7 +480,7 @@ export function generateCodeFrame( const lineLength = lines[j].length if (j === i) { // push underline - const pad = start - (count - lineLength) + 1 + const pad = Math.max(start - (count - lineLength) + 1, 0) const length = Math.max( 1, end > count ? lineLength - pad : end - start