-
-
Notifications
You must be signed in to change notification settings - Fork 648
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
cider-format-buffer can delete whole buffer's contents on invalid Clojure syntax #2102
Comments
I do get that buffer! (Hadn't noticed before; under my setup most 'foreign' windows/buffers don't pop up)
I just enabled
|
You get the error buffer but the contents of the source buffer is still erased? I don't get that. Can you try w/ |
Can't `-Q` since that would't load CIDER or anything. At least that's how
my emacs initialization is organized...
Tried disabling various stuff in my init; no luck.
I played a bit with the cider elisp code. I'd say the issue is:
`(cider-sync-request:format-code "(")` returns nil, but the
`cider--format-buffer` implementation expects a string somewhere.
You might be able to reproduce with: (cider--format-buffer (lambda (_) nil))
|
I know the issue!
Fix: - unless (equal original formatted)
+ (unless (or (not formatted) (equal original formatted)))
... |
Still doesn't explain why you're seeing this issue that I'm not. An unmatched paren like that should result in an EOF error thrown by the reader that stops everything in its tracks, not wipe the buffer. |
It is reasonable to try determining the exact cause, however as usual my
emacs setup has accumulated lots of stuff over the years. Bisecting could
be a painful effort.
Nil check seems cheap?
Cheers - Victor
…On Tue, Oct 31, 2017 at 11:59 PM, Tianxiang Xiong ***@***.***> wrote:
Still doesn't explain why you're seeing this issue that I'm not. An
unmatched paren like that should result in an EOF error thrown by the
reader.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#2102 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ABG-8kI7o8xgtiFnS8rTwI8kKpMbNphXks5sx6ZhgaJpZM4QNYhl>
.
|
If someone else can reproduce (cc @bbatsov), I'll look into it further. Randomly adding null checks is not the way to go. |
I agree. I'll try to find some time to test this myself. |
I can't reproduce this myself - I get exactly the same results as @xiongtx. |
I've also checked the message exchange between CIDER and nREPL and there's no response except the error. At any rate there's a real problem here that's easy to fix - the middleware should gracefully handle bad code and send back some meaningful message to CIDER. |
Basically the code here https://github.com/clojure-emacs/cider-nrepl/blob/master/src/cider/nrepl/middleware/format.clj#L13 should feature some exception handling and return some meaningful message to CIDER when this happens. |
(or we can add |
Given the following clojure buffer with a dangling parens (doesn't matter if it has a ns form):
if I run
(cider-format-buffer)
, the whole buffer's contents will disappear.Issue is easy to cleanly reproduce; GH template seems excessive in this case.
Using:
Cheers - Victor
The text was updated successfully, but these errors were encountered: