Fix an issue where in translit tokens the line count was not incremented - #66
Merged
Conversation
Contributor
There was a problem hiding this comment.
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.erlto handle\nand\r\nwhile 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.
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.
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:
template_compiler_scanner.erlto correctly handle\nand\r\nline breaks inside translation literals, incrementing the row and resetting the column as needed.Test enhancements:
template_compiler_quote_SUITE.erlfor multi-line translation literals and comments to verify correct token position tracking. [1] [2]template_compiler_trans_SUITE.erlfor multi-line translation text to ensure accurate token positions after line breaks. [1] [2]