Skip to content

Conversation

@idoros
Copy link
Contributor

@idoros idoros commented Aug 29, 2023

This PR addresses the issue of source.end.offset being off by one.

The problem stemmed from direct use of the token location as the offset when resolving line and column with getPosition(), which worked well for start.offset, but should point to the index immediately after the node for the end.offset to ensure that source.slice(start.offset, end.offset) provides the correct node source.

The solution is straightforward: I've reviewed the parser's instances where the end offset is set and made a simple adjustment off adding 1 (except the final root location that works as expected).

There are still 30 failing tests originating from postcss-parser-tests that needs to have their expectation JSON adjusted - I probably need some help making that change, thank you in advance!

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.

2 participants