Render error caret for the last character of the parsing context - #627
Open
fudianchn wants to merge 1 commit into
Open
Render error caret for the last character of the parsing context#627fudianchn wants to merge 1 commit into
fudianchn wants to merge 1 commit into
Conversation
ParsingException.getMessage() guards the caret rendering with `column < context.length()`, but `column` is 1-indexed (the caret is drawn at position `column - 1`), so when the error is at the last character (column == context.length()), the caret was not rendered. Use `<=` so the caret is shown for the last character too, while still rejecting positions past the end of the context. A comment notes the 1-indexing so the boundary is not flipped back by mistake. Closes SpongePowered#625 Signed-off-by: 付典 <fudianchn@gmail.com>
fudianchn
force-pushed
the
fix-caret-last-column
branch
from
August 13, 2026 04:46
effbe59 to
15919cd
Compare
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.
Problem
ParsingException.getMessage()renders a caret (^) under the error column, but guards it withcolumn < context.length(). Becausecolumnis 1-indexed (the caret is drawn at positioncolumn - 1), the caret is dropped when the error is on the last character, i.e.column == context.length()(#625).Fix
<=renders the caret for the last character (at positioncolumn - 1) while still rejecting positions past the end. A short comment notes the 1-indexing so the boundary is not flipped back by mistake.Verification
The caret branch from
getMessage(), with context"hello"(length 5):<) caret?<=) caret?5(== length, last char)3(mid)6(> length, past end)Added
ParsingExceptionTest:caretRenderedForLastColumnasserts the caret is rendered AND aligned under the last character (checks(length - 1)leading spaces, not just that a^appears).caretNotRenderedBeyondContextasserts no caret is rendered past the end../gradlew :core:checkstyleMain :core:checkstyleTestpasses locally.Closes #625