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

VueTransformer uses nonsensical values for codeFrames.codeHighlights line numbers #8500

Closed
lol768 opened this issue Sep 23, 2022 · 0 comments · Fixed by #8501
Closed

VueTransformer uses nonsensical values for codeFrames.codeHighlights line numbers #8500

lol768 opened this issue Sep 23, 2022 · 0 comments · Fixed by #8501

Comments

@lol768
Copy link
Contributor

lol768 commented Sep 23, 2022

I mentioned in my PR (#8499) that the code previews don't work and hypothesised I was doing something wrong.

Looking at the line numbers it was generating, they're all nonsensical:

line: err.loc.start.line + err.loc.start.offset,

I don't get what this is supposed to do, but it generates line numbers like 1483 in a 155 line file!

Looking at the Vue SFC compiler's code

https://github.com/vuejs/core/blob/fbd697a4b6c238147d661026836314862fd09221/packages/compiler-sfc/src/compileTemplate.ts#L307-L312

It's already adjusting the line numbers by an offset, and indeed if I change the code to not add this offset, the code previews start to work fine:

if (err.loc) {
  diagnostic.codeFrames = [{
    filePath,
    codeHighlights: [{
      start: {
        line: err.loc.start.line,
        column: err.loc.start.column
      },
      end: {
        line: err.loc.end.line,
        column: err.loc.end.column
      }
    }]
  }];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants