Add Input mode for collapse_simple_statement#1112
Open
ddashdev wants to merge 5 commits into
Open
Conversation
Author
|
Also closes #863 |
bump to stylua@2.5.2
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.
Adds a new
Inputmode forcollapse_simple_statement.It allows Stylua to preserve whether simple functions and conditionals were originally collapsed or expanded, instead of enforcing one global collapse behavior across the whole codebase.
With this mode:
stays collapsed, while:
stays expanded.
The motivation is making it possible for users to keep a mixed style where some simple statements are collapsed and others are intentionally expanded, not all simple statements carry the same importance in a codebase. In some cases a collapsed statement improves readability by keeping a guard clause or empty function compact, while in others, expanding the statement makes the control flow or intent more visible.
The existing
collapse_simple_statementmodes require users to choose one global behavior: collapse matching statements everywhere, or expand them everywhere. This can be limiting when different simple statements benefit from different formatting choices.And, while
stylua: ignorecomments can work around individual cases, they add noise and become difficult to maintain when used repeatedly for formatting preferences. Adding anInputmode follows the existing input-preserving semantics used by other Stylua rules likecall_parenthesis, and gives users the ability to preserve these choices per situation without changing the default behavior.Note: I used AI assistance while working through parts of the implementation, but reviewed the resulting changes and verified the behavior with tests.