fix: handle all CSS newline types in CSSSourceCode
#275
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Prerequisites checklist
What did you do?
What did you expect to happen?
CSSSourceCode.lines
returns the correct array of lines.getLocFromIndex
andgetIndexFromLoc
return correct line/column positions.What actually happened?
Lines containing CR or FF were not split, causing incorrect line/column calculations.
What is the purpose of this pull request?
According to the CSS Syntax Module Level 3, CSS defines newline as one of:
\n
)\r\n
)\r
)\f
)CSSSourceCode
previously only handled LF and CRLF correctly because it relied on the defaultlineEndingPattern
fromTextSourceCodeBase
(/\r?\n/
).This PR ensures
CSSSourceCode
aligns with the CSS specification for newline handling.What changes did you make? (Give an overview)
CSSSourceCode
to passlineEndingPattern: /\r\n|[\r\n\f]/u
toTextSourceCodeBase
.Related Issues
fixes #276
Is there anything you'd like reviewers to focus on?