Repository navigation
Conversation
prev steps back one UTF-16 code unit, including across the synthetic newline between lines, and leaves the position unchanged at the start of the input. findPrev searches backward for a character or a CharMatcher, with overloads that take an inclusive lower position so the search can stop at a saved opener. The current character is included, the end sentinel is skipped and never matches, a hit returns how many code units were moved, and a miss returns -1 while staying at the start of the input or at the bound. A bound after the current position or outside the input throws IllegalArgumentException before the position changes. Fixes commonmark#395
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.
Why
A custom inline parser that has already read an opener often needs the last closer before the next whitespace or the end of the text. Reaching that closer from the current position means scanning forward and scanning again to confirm the match is the last one, which is awkward for the caller and does extra work.
What changed
Testing
./mvnw -B -ntp -pl commonmark -am test -Dtest=InlineContentParserTest,ScannerTest -Dsurefire.failIfNoSpecifiedTests=falsepassed locally (ScannerTest 11 tests, InlineContentParserTest 3 tests, no failures). The same command passed 14 tests in a Linux container (eclipse-temurin:21-jdk).Fixes #395