pinterest / ktlint

An anti-bikeshedding Kotlin linter with built-in formatter
https://pinterest.github.io/ktlint/
MIT License
6.06k stars 504 forks source link

Suport partial formatting of code #2629

Closed paul-dingemans closed 2 months ago

paul-dingemans commented 2 months ago

Currently the KtlintRuleEngine.format(..) function applies formatting on the entire file or code snippet. For the ktlint-intellij-plugin (https://github.com/nbadal/ktlint-intellij-plugin/issues/385) it is preferred that it possible to only format a selection of the file or code snippet. By passing a range of offsets (start and end offset) the KtlintRuleEngine can apply the autocorrect mode only on nodes for which the startoffset of the node is within the given range of offsets.