Repository navigation
Conversation
|
The CI failure looks like a bootstrap compatibility issue - can't add a new param without breaking ktfmt-gradle since it's statically compiled against the only one? I tried adding |
hick209
left a comment
There was a problem hiding this comment.
Love the work you did here! Thank you so much and sorry it took so long to get to this.
I am not fully confident on exposing this via CLI flag yet, everything else LGTM.
Regardless I'll pull it internally for review.
|
@hick209 has imported this pull request. If you are a Meta employee, you can view this in D105690093. |
hick209
left a comment
There was a problem hiding this comment.
Oh, please do not forget to update the CHANGELOG.md
|
Updated the changelog and added another constructor overload. For the latter - it may be valuable before 1.0.0 to expose a Builder API for this to avoid the churn for tools programmatically calling this |
|
Doesn't look like we can get away with an overload |
|
Debugged offline via Slack |
Add new boolean configuration option to FormattingOptions and wire it through the command-line interface. This option will enable cascading lambda break decisions to nested trailing lambdas, useful for DSLs like Jetpack Compose. Changes: - Add cascadeNestedLambdaBreaks field to FormattingOptions data class - Add --cascade-nested-lambda-breaks command-line flag to ParsedArgs - Update CLI help text to document the new option - Default value is false to maintain backward compatibility ðĪ Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
Add parentLambdaBroke parameter to track parent lambda break state through nested lambda expressions. Add helper method to identify trailing lambdas that should inherit hierarchy preservation. Changes: - Add parentLambdaBroke parameter to visitLambdaExpressionInternal - Add isTrailingLambda helper method to detect trailing lambdas - Update method documentation to explain new parameter - All call sites use default value (false) for now No functional changes yet - context is passed but not used. ðĪ Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
Implement the core cascading lambda break functionality. When cascadeNestedLambdaBreaks is enabled and a parent lambda breaks to multi-line, all nested trailing lambdas are forced to break as well, preserving visual hierarchy. Changes: - Add insideBreakingLambda member variable to track break state - Detect when current lambda will break to multi-line - Force nested trailing lambdas to multi-line when parent broke - Propagate break state through nested lambda visitor calls - Update visitArgumentInternal and visitLambdaOrScopingFunction The feature is now functional when --cascade-nested-lambda-breaks flag is enabled. Backward compatible - default behavior unchanged. ðĪ Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
Add 7 comprehensive test cases covering various scenarios for the cascadeNestedLambdaBreaks feature. Tests verify basic hierarchy preservation, backward compatibility, deep nesting, edge cases, and that only trailing lambdas are affected. Changes: - Add test for forcing nested lambda hierarchy when option enabled - Add test for maintaining single line when option disabled - Add test for forcing only trailing lambdas (not map/filter) - Add test for forcing behavior when parent breaks - Add test for preserving hierarchy with multiple statements - Add test for handling deep nesting levels - Add test for no effect on non-nested lambdas - Fix containsTrailingLambdas to correctly detect nested lambdas - Update break detection logic to handle hierarchy properly All tests pass, feature fully functional. ðĪ Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
Document the new --cascade-nested-lambda-breaks command-line option in the README with examples and usage guidelines. The documentation explains how the feature helps preserve visual hierarchy in DSL code like Jetpack Compose. Changes: - Add "Cascading Lambda Breaks" section to README.md - Include usage examples showing before/after formatting - Clarify that option only affects trailing lambdas - Note that it's useful for DSLs with semantic nesting Feature is now fully implemented, tested, and documented. ðĪ Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
4418c9d to
c7a7e58
Compare
--preserve-lambda-breaks option
This is a continuation of #574 with the updated option control to orient around the requested
--preserve-lambda-breakssimple option. With this, lambda block line breaks are simply just respected rather than have ktfmt impose anything.Aside from finishing up the previous PR, this also adds a setting to the IJ plugin.
I cherrypicked the original commits to preserve authorship history (CC @loganj)
Resolves #547
Edit
After chatting on slack I updated the PR with a couple things: