kkinnear / zprint

Executables, uberjar, and library to beautifully format Clojure and Clojurescript source code and s-expressions.
MIT License
554 stars 47 forks source link

zprint deletes form #173

Closed atdixon closed 3 years ago

atdixon commented 3 years ago

Yikes! zprint deleted some of our code...

I've tested this with zprint 1.0.2 and 1.1.0.

When :list {:respect-nl? true} is configured, zprint quietly deletes this anonymous fn form:

;; yikes! this form is deleted!
(fn [x]
  (bar)
   )

But incidentally not if the fn is named:

;; all is good
(fn foo [x]
  (bar)
   )

Nor if there is no hanging parens:

;; all is good
(fn foo [x]
  (bar))
kkinnear commented 3 years ago

That's not good. Thanks for noticing! I'll get right on it. Looks like we'll have a 1.1.1 real soon now. There was one very obscure problem where some code went away several years ago, but generally the tests have caught the few problem like this that have occurred. Fortunately, I'm all set up for another release and not in the middle of anything right now.

kkinnear commented 3 years ago

I have found and fixed this problem. Near as I can tell, it requires the use of {:list {:respect-nl? true}} as you noted as well as the hanging parenthesis at the end. Thank you very much for the time you spent running down what did and didn't work and reducing it to a small example. You probably cut my debugging time at least in half, if not more. I really appreciate the effort! I have fixed this and just need to run some more tests. I hope to release the fixed version, 1.1.1 tomorrow, or possibly Thursday as tomorrow is already pretty full. Thanks again for alerting me to this!

atdixon commented 3 years ago

Thanks Kim for the update! Will keep an eye out.

kkinnear commented 3 years ago

Fixed in 1.1.1. Thanks again for noticing this and making a small example to replicate it!