-
-
Notifications
You must be signed in to change notification settings - Fork 5.6k
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
@babel/code-frame incorrectly marks lines containing tab characters #12696
Comments
Hey @jaydenseric! We really appreciate you taking the time to report an issue. The collaborators on this project attempt to help as many people as possible, but we're a limited number of volunteers, so it's possible this won't be addressed swiftly. If you need any help, or just have general Babel or JavaScript questions, we have a vibrant Slack community that typically always has someone willing to help. You can sign-up here for an invite." |
Includes a workaround in tests for babel/babel#12696 .
Includes a workaround in tests for babel/babel#12696 .
There are two different questions:
|
It seems tabs and visual alignment of the markers have been accounted for in the past, but only for far-left indentation in lines: I don't see the harm in making sure the markers line up correctly by indenting them with a combination of tabs and spaces, as required. |
At least in vscode and gedit they are counted as multiple columns, while vim gives you both the number counting them as 1 and as multiple. Anyway, this is probably easier to fix in |
Here is step-by-step example. I'm using Notice in this example, the user has indent-aligned the JSDoc tag values using spaces. The link to the start of the problem code location can be CMD+Clicked in VS Code, and you can see that it places the carrot at the right spot: Now, lets try the same thing but with the JSDoc tag values indent-aligned using tabs instead of spaces: As you can see, the start column number is correct how it is. What is incorrect is the way |
I re-investigated the issue and found that the problem came from the const { codeFrameColumns } = require("@babel/code-frame");
const code = "x\t\tabc";
console.log(
codeFrameColumns(
code,
{
start: { line: 1, column: 4 },
end: { line: 1, column: 7 },
},
{ forceColor: true }
)
);
console.log(
codeFrameColumns(
code.replace(/\t/g, " "),
{
start: { line: 1, column: 4 },
end: { line: 1, column: 7 },
},
{ forceColor: true }
)
); |
Bug Report
Current behavior
The
@babel/code-frame
functioncodeFrameColumns
incorrectly marks a location in a line that follows tab characters; the markers are not indented using the right mix of spaces and tab characters to indent enough to visually line up with the characters being marked.Example:
Expected behavior
Code frame markers horizontally line up visually with the characters being marked.
Environment
@babel/code-frame
: v7.12.11The text was updated successfully, but these errors were encountered: