Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use :block rule as baseline indentation for :stair rule #98

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

bullfest
Copy link

Fix #97

Sorry about opening this before the underlying issue has been responded to, I had some extra time and thought I'd try my proposed fix.

A better solution might be to introduce a new rule instead, or add extra parameters to the rule as this would change some behaviour when leading forms are missing (see my comment in the tests).

indent/reindent-lines {:indents indents}
;; Note that this is parsed "wrong" as the expr-part is missing from the cond->
"(cond-> a? (a 123)\n b?\n(b true))"
(str "(cond-> a? (a 123)\n" (space 13) "b?\n" (space 11) "(b true))")))
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is some changed behaviour that I don't think would be possible to keep backwards compatibility with, afaik there's no way for the stair-indentation to tell if the form that's on the same line is the "leading form" (expr in cond->) or if it's a condition that's on the same line...

Copy link
Author

@bullfest bullfest Feb 21, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On further consideration, it could be solved by only using block-indent as the base when the idx parameter is 0 which probably is reasonable.

Things like

(cond-> x a? (a 123) 
          b? (b true))

is quite silly after all and probably not something that should be encouraged.

@codecov-commenter
Copy link

Codecov Report

Base: 89.82% // Head: 89.83% // Increases project coverage by +0.01% 🎉

Coverage data is based on head (e2f7ef2) compared to base (14c18e5).
Patch coverage: 100.00% of modified lines in pull request are covered.

📣 This organization is not using Codecov’s GitHub App Integration. We recommend you install it so Codecov can continue to function properly for your repositories. Learn more

Additional details and impacted files
@@            Coverage Diff             @@
##             main      #98      +/-   ##
==========================================
+ Coverage   89.82%   89.83%   +0.01%     
==========================================
  Files          20       20              
  Lines        1907     1909       +2     
  Branches       60       60              
==========================================
+ Hits         1713     1715       +2     
  Misses        134      134              
  Partials       60       60              
Impacted Files Coverage Δ
src/cljstyle/format/indent.clj 93.56% <100.00%> (+0.07%) ⬆️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

:stair does not behave like documented when multiple arguments on first line
2 participants