Conversation
Source::getLocation() subtracted the byte offset of the last line terminator from a character position, so every multibyte character on earlier lines shifted the column to the left, down to zero or negative values. 🤖 Generated with Claude Code
🤖 Generated with Claude Code
Contributor
There was a problem hiding this comment.
Copilot review overview
🟢 Approval recommended
The implementation correctly handles character offsets and includes focused regression coverage.
Review effort: Balanced
Findings: None
What changed in this PR
Fixes source-location columns following multibyte characters by calculating the current line’s character length.
Changes:
- Splits the source prefix into lines to derive accurate line and column values.
- Adds coverage for multibyte characters and varied line separators.
- Documents the fix.
| File | Description |
|---|---|
src/Language/Source.php |
Corrects line and column calculation. |
tests/Language/SourceTest.php |
Adds source-location regression tests. |
CHANGELOG.md |
Records the fix. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Syntax error columns are wrong after any line that contains a multibyte character.
Source::getLocation()subtracted a byte offset from a character position.It now counts the characters after the last line terminator.
{ a }\nxx?# ä\n{ a }\nxx?# äää\nxx?Found by Copilot on https://github.com//pull/1987
#1987 (comment) reported the wrong column for invalid UTF-8 after a multibyte line.
The cause is older than that pull request and affects every syntax error.
🤖 Generated with Claude Code