Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

generateCodeFrame fails for files >= 1000 lines #1806

Closed
jsmith opened this issue Aug 7, 2020 · 0 comments · Fixed by #1807
Closed

generateCodeFrame fails for files >= 1000 lines #1806

jsmith opened this issue Aug 7, 2020 · 0 comments · Fixed by #1807

Comments

@jsmith
Copy link
Contributor

jsmith commented Aug 7, 2020

Version

3.0.0-rc.5

Reproduction link

https://codesandbox.io/s/wonderful-shirley-8g3zu?file=/src/index.js

Steps to reproduce

Once you open this codesandbox, the error will show up right away! This is happening because the source file is 1000 lines long and the line # formatter only works for files < 1000 lines.

What is expected?

This prints a codeframe.

What is actually happening?

It fails due to a bad range (RangeError Invalid count value).


I ran into this bug when my vite build was trying to print out some kind of warning but my compiled js was > 10,000 lines long.The easiest solution would be to just add a Math.max here to catch this edge case. To be more specific, change:

res.push(`${line}${' '.repeat(3 - String(line).length)}|  ${lines[j]}`)

to:

res.push(`${line}${' '.repeat(Math.max(3 - String(line).length, 0))}|  ${lines[j]}`)

Thanks for your help :)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant