Skip to content

Commit 3af6a1b

Browse files
authored
fix: prevent crash when the pad amount is negative (#8747)
1 parent 4eb2348 commit 3af6a1b

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

packages/vite/src/node/utils.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -480,7 +480,7 @@ export function generateCodeFrame(
480480
const lineLength = lines[j].length
481481
if (j === i) {
482482
// push underline
483-
const pad = start - (count - lineLength) + 1
483+
const pad = Math.max(start - (count - lineLength) + 1, 0)
484484
const length = Math.max(
485485
1,
486486
end > count ? lineLength - pad : end - start

0 commit comments

Comments
 (0)