Skip to content

Fix lexer column tracking - #803

Merged
ydah merged 1 commit into
masterfrom
fix/lexer-columns
Sep 5, 2026
Merged

Fix lexer column tracking#803
ydah merged 1 commit into
masterfrom
fix/lexer-columns

Conversation

@ydah

@ydah ydah commented Sep 5, 2026

Copy link
Copy Markdown
Member

Lexer#column used StringScanner#pos directly, causing columns after multibyte characters to be reported as byte offsets.

Whitespace scanning also consumed newlines together with indentation from the following line. This moved the line-start position past the indentation and incorrectly reported column zero.

Calculate columns as character offsets and process newlines separately from other whitespace. Add regression coverage for indented lines with trailing whitespace and multibyte input.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟢 Approval recommended

The changes directly address the described column-tracking defects and include targeted regression tests for both indentation and multibyte scenarios.

Pull request overview

This PR fixes incorrect lexer column reporting by computing columns as character offsets (not byte offsets) and by avoiding newline consumption as part of generic whitespace scanning, which previously caused indentation columns to be misreported after line breaks.

Changes:

  • Compute Lexer#column as a character count from the current line start to the scanner position.
  • Scan \n separately from other whitespace so indentation after a newline doesn’t reset the line-start pointer incorrectly.
  • Add regression specs for indented trailing-whitespace lines and multibyte input.
File summaries
File Description
spec/lrama/lexer_spec.rb Adds regression coverage for indentation-after-newline column reporting and multibyte character column offsets.
lib/lrama/lexer.rb Updates column calculation and refines whitespace/newline scanning to preserve correct line-start tracking.
Review details
  • Files reviewed: 2/2 changed files
  • Comments generated: 0
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@ydah
ydah merged commit f58bbe4 into master Sep 5, 2026
46 checks passed
@ydah
ydah deleted the fix/lexer-columns branch September 5, 2026 07:32
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