Skip to content

code frame formatting messed up when using colors #10159

Description

@devsnek

Bug Report

Current Behavior
Using color in code frames causes odd formatting

Input Code

console.log(codeFrameColumns(`
function a(b, c) {
  return b + c;
}
`, {
  start: {
    line: 2,
    column: 1,
  },
  end: {
    line: 4,
    column: 1,
  },
}, {
  highlightCode: true,
  message: 'Message about things',
}));

Expected behavior/code
Arrow formatting remains consistent

Environment

  • @babel/code-frame: 7.0.0

Possible Solution

Additional context/Screenshots

Input code from above with and without highlightCode:

--

P.S. it also seems that with the non-color output, the first line is 1 character short.

Metadata

Metadata

Assignees

No one assigned

    Labels

    outdatedA closed issue/PR that is archived due to age. Recommended to make a new issue

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions