greglook / cljstyle

A tool for formatting Clojure code
Eclipse Public License 1.0
293 stars 39 forks source link

:stair does not behave like documented when multiple arguments on first line #97

Open bullfest opened 1 year ago

bullfest commented 1 year ago

The documentation says

A :stair rule is similar to :block, except that it tries to indent test/expression clauses as pairs.

From this I'd expect the following snippet to be correctly formatted when having the indentation rule {cond [[:stair 0]]}

(cond (pos? n) 
        1
      (neg? n) 
        -1
      :else 
        0)

but it's formatted to

(cond (pos? n) 
    1
  (neg? n) 
    -1
  :else 
    0)

Same with

(cond (pos? n) 1
      (neg? n) -1
      :else 0)

which is formatted to

(cond (pos? n) 1
  (neg? n) -1
  :else 0)

The most reasonable behaviour in my mind for :stair is to have a base indentation that matches :block, and then add extra indentation for every other element after the one that the index is provided for.

I think it should be reasonable enough to have the same index be the basis for the :block and :stair parts of the rule.