Skip to content

Add Input#fromLineAndColumn, CssSyntaxError.input.offset and CssSyntaxError.input.endOffset#2034

Merged
ai merged 6 commits intopostcss:mainfrom
mizdra:add-offset-props-in-file-position
Mar 22, 2025
Merged

Add Input#fromLineAndColumn, CssSyntaxError.input.offset and CssSyntaxError.input.endOffset#2034
ai merged 6 commits intopostcss:mainfrom
mizdra:add-offset-props-in-file-position

Conversation

@mizdra
Copy link
Copy Markdown
Contributor

@mizdra mizdra commented Mar 22, 2025

fix: #2022

I initially tried to add CssSyntaxError.offset and CssSyntaxError.endOffset. But in the case of CSS with source map, it is always undefined. The sourcemap has the original line and column, but not the offset.

Instead, I added CssSyntaxError.input.offset and CssSyntaxError.input.endOffset. CssSyntaxError.input is a property with a location that ignores the sourcemap. I thought it appropriate to add offset and endOffset here.

I needed Input#fromLineAndColumn to implement the properties. So I have added that as a public API.


is(error.file, join(__dirname, 'b.css'))
is(error.line, 2)
is(error.column, 0) // Is this correct?
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

It appears that the columns restored from the sourcemap are smaller by 1. This may be a bug.

I will investigate the details and create an issue.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

OK. Let’s merge it and think about it in separated issues/PRs.

@ai ai merged commit f82c2a6 into postcss:main Mar 22, 2025
9 checks passed
@ai
Copy link
Copy Markdown
Member

ai commented Mar 22, 2025

Amazing. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add CssSyntaxError.offset and CssSyntaxError.endOffset

2 participants