Skip to content

Fix an issue where in translit tokens the line count was not incremented - #66

Merged
mworrell merged 1 commit into
masterfrom
linecount-translit
Mar 25, 2026
Merged

Fix an issue where in translit tokens the line count was not incremented#66
mworrell merged 1 commit into
masterfrom
linecount-translit

Conversation

@mworrell

Copy link
Copy Markdown
Member

This pull request improves the handling of multi-line input in the template compiler scanner and adds corresponding tests to ensure correct token position tracking for multi-line constructs. The main focus is on ensuring that line breaks within translation literals and comments are properly processed, and that token positions are accurately maintained.

Scanner improvements:

  • Updated template_compiler_scanner.erl to correctly handle \n and \r\n line breaks inside translation literals, incrementing the row and resetting the column as needed.

Test enhancements:

  • Added tests in template_compiler_quote_SUITE.erl for multi-line translation literals and comments to verify correct token position tracking. [1] [2]
  • Added a test in template_compiler_trans_SUITE.erl for multi-line translation text to ensure accurate token positions after line breaks. [1] [2]

Copilot AI review requested due to automatic review settings March 25, 2026 21:16

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes template scanner position tracking for multi-line translation text blocks by correctly incrementing the line counter (row) and resetting the column when encountering line breaks within {_ ... _} constructs, and adds regression tests to validate token positions after multi-line constructs.

Changes:

  • Update template_compiler_scanner.erl to handle \n and \r\n while scanning inside translation text blocks (in_trans), updating {Row, Column} correctly.
  • Add Common Test cases asserting identifier token positions after multi-line translation literals, translation text blocks, and comments.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
src/template_compiler_scanner.erl Adds explicit newline handling for in_trans to keep row/column tracking correct across line breaks.
test/template_compiler_quote_SUITE.erl Adds token-position regression tests for multi-line trans literals and multi-line comments.
test/template_compiler_trans_SUITE.erl Adds a token-position regression test for multi-line translation text blocks.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/template_compiler_scanner.erl
@mworrell
mworrell merged commit 89581f2 into master Mar 25, 2026
7 checks passed
@mworrell
mworrell deleted the linecount-translit branch March 25, 2026 21:21
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