Skip to content

fix: caret position was incorrect#14984

Merged
bluwy merged 5 commits intovitejs:mainfrom
sapphi-red:fix/generate-code-frame
Nov 15, 2023
Merged

fix: caret position was incorrect#14984
bluwy merged 5 commits intovitejs:mainfrom
sapphi-red:fix/generate-code-frame

Conversation

@sapphi-red
Copy link
Copy Markdown
Member

@sapphi-red sapphi-red commented Nov 14, 2023

Description

generateCodeFrame was generating a incorrect caret position when column was 0.

close #14381
fixes #14312
refs #8747

Also fixes/improves some other things:

  • esbuild error position was a bit wrong:

    Before

    Unterminated string literal
    1  |  export const bar = 'bar
       |                         ^
    2  |  
       |  ^
    

    After

    Unterminated string literal
    1  |  export const bar = 'bar
       |                         ^
    2  |  
    
  • add end position for parse5, postcss, dynamic import warning:

    Before

    1  |  <head>
    2  |    <noscript><noscript></noscript></noscript>
       |              ^
    3  |  
    4  |  </head>
    

    After

    1  |  <head>
    2  |    <noscript><noscript></noscript></noscript>
       |              ^^^^^^^^^^
    3  |  
    4  |  </head>
    

Additional context


What is the purpose of this pull request?

  • Bug fix
  • New Feature
  • Documentation update
  • Other

Before submitting the PR, please make sure you do the following

  • Read the Contributing Guidelines, especially the Pull Request Guidelines.
  • Check that there isn't already a PR that solves the problem the same way to avoid creating a duplicate.
  • Provide a description in this PR that addresses what the PR is solving, or reference the issue that it solves (e.g. fixes #123).
  • Update the corresponding documentation if needed.
  • Ideally, include relevant tests that fail without this PR but pass with it.

@sapphi-red sapphi-red added the p3-minor-bug An edge case that only affects very specific usage (priority) label Nov 14, 2023
@sapphi-red sapphi-red marked this pull request as draft November 14, 2023 15:36
@sapphi-red sapphi-red force-pushed the fix/generate-code-frame branch from 8f3d10b to 2d348c9 Compare November 14, 2023 16:05
@sapphi-red sapphi-red marked this pull request as ready for review November 14, 2023 16:06
Copy link
Copy Markdown
Member

@patak-cat patak-cat left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is awesome! I think it would be good to still merge it as part of Vite 5 to get all the tests in the major. I'll wait for @bluwy to merge it though in case we want to freeze at the latest beta already.

Copy link
Copy Markdown
Member

@bluwy bluwy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great! I think we can merge it straight away too

@bluwy bluwy merged commit 2b4e793 into vitejs:main Nov 15, 2023
@sapphi-red sapphi-red deleted the fix/generate-code-frame branch November 15, 2023 07:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

p3-minor-bug An edge case that only affects very specific usage (priority)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Caret in on-screen error output points to the wrong line

3 participants