Add --range-start and --range-end CLI options for range formatting - #676
Open
samccone wants to merge 1 commit into
Open
Add --range-start and --range-end CLI options for range formatting#676samccone wants to merge 1 commit into
samccone wants to merge 1 commit into
Conversation
Implement character offset-based range formatting inspired by Prettier's range options (--range-start and --range-end). Features: - `--range-start <int>`: start offset (inclusive, defaults to 0) - `--range-end <int>`: end offset (exclusive, defaults to EOF) - Support independent or paired usage with robust bounds validation - Safe range clamping in Formatter and KotlinInput to prevent out-of-bounds errors - Shebang offset adjustment and line-ending preservation - Expanded unit and integration test coverage across CLI, Tokenizer, and Formatter Fixes: Kotlin#573, Kotlin#388
AbdullinAM
requested changes
Aug 20, 2026
Member
There was a problem hiding this comment.
Hi! Thank you for the contribution! I have some comments on the PR, but before doing a full review, can you please explain your motivation/use case for adding new CLI options for functionality that is already supported by ktfmt via --offset and --length?
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.
Implement character offset-based range formatting inspired by Prettier's range options (--range-start and --range-end).
Features:
--range-start <int>: start offset (inclusive, defaults to 0)--range-end <int>: end offset (exclusive, defaults to EOF)Fixes: #573, #388