Repository navigation
fix(syntax): handle column offset at file start - #678
Open
poplolioi11 wants to merge 1 commit into
Open
poplolioi11 wants to merge 1 commit into
poplolioi11 wants to merge 1 commit into
Conversation
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.
When a source starts with LF,
columnOffset(source, 0)returns-1instead of0. The backwards search passes-1tolastIndexOf, which clamps it to index 0 and incorrectly counts the leading LF as preceding the requested position.Return 0 before searching at the file-start position. Add nine regression/control tests for leading LF, empty/plain sources, CRLF, positions on and after a newline, consecutive newlines, and EOF. Positive offsets retain the existing behavior.
Fixes #674.
Validation on main
9a925d2:@fluent/syntax@0.19.0with the built patched public API in real headless Chromium 151, Firefox 153, and WebKit 26.5: 2 incorrect results before, 0 after, for 14 cases per engine.The demonstrated impact is an invalid coordinate from the public helper. No downstream production failure has been established, and this change does not add validation for out-of-range or negative positions.
AI assisted source/test preparation and a separate static review; the validation results above were obtained by local execution.