clj-refactor.nvim icon indicating copy to clipboard operation
clj-refactor.nvim copied to clipboard

`cril` (introduce let) does not properly indent the body of the new `let` form

Open daveyarwood opened this issue 7 years ago • 0 comments

For example, I have this top-level form:

(defrpc campaigns
  [& [opts]]
  {:rpc/pre (and (have-api-key) (have-network))}
  (->> (view/campaigns (network) opts)
       (map #(safe-parse-json % :customfields))))

When I put my cursor on the ( before ->> and enter cril and enter cs for the binding name, the result is:

(defrpc campaigns
  [& [opts]]
  {:rpc/pre (and (have-api-key) (have-network))}
  (let [cs (->> (view/campaigns (network) opts))]
       (map #(safe-parse-json % :customfields))))
cs

I use parinfer, so it re-balanced my parens because cs was all the way to the left, so it was judged to be another top-level form. The bindings part of the let also got closed prematurely because the line after it wasn't indented far enough to the right.

If I disable parinfer and do the same thing, I get this, which is still not indented properly:

(defrpc campaigns
  [& [opts]]
  {:rpc/pre (and (have-api-key) (have-network))}
  (let [cs (->> (view/campaigns (network) opts)
       (map #(safe-parse-json % :customfields)))]
cs))

Note that not only is cs not indented at all, the previous line also has incorrect indentation now because it didn't move from where it was before.

daveyarwood avatar May 18 '18 13:05 daveyarwood