-
-
Notifications
You must be signed in to change notification settings - Fork 222
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
Format doesn't work properly if ##Inf is involved #870
Comments
Hello fellow Manjaro user 😃. This sounds really strange. Have you changed any formatting settings? (https://calva.io/formatting/#configuration). The only other thing off the top of my head that can be affecting it is other extensions. Have you tried disabling all other extensions (clj-kondo is fine to leave enabled), and then seeing if it behaves the same? |
Hi, thanks for your help! AFAIK I haven't changed any formatting settings. I don't have any I tried disabling all extensions except Calva, or Calva and clj-kondo, but there is no change in the behavior. Here's another thing I found: if I try to run the command 'Calva Format: Format Current Form', or a similar command, I also get the pop-up error "Running the contributed command: 'calva-fmt.formatCurrentForm' failed." or equivalent. |
Very strange! Does it help to make click between some different clojure files? Thinking that maybe Calva gets confused about what is the active window, when the output window is activated.... |
Thanks for the input! I've tried opening multiple Clojure files, opening a single Clojure file, having VS Code's Output window opened or closed, but none of it made a difference in the behavior. I will experiment some more later when I have time, and try to gather more data about the problem. |
@MareinK If you can give code that the issue happens with, all the code in the file (can make a small sample file to make it simpler to analyze), maybe we can see if something in the code is tripping up the formatter. |
@bpringe Thanks! I've currently shifted my experiments with Clojure/Calva to the browser with ClojureScript and shadow-cljs, so I haven't been in a situation where the REPL problem popped up. However, I will take some time soon to look into the problem again and try to produce a minimal example. |
Hi! Sorry for taking so long to look into this. I had a look now and I'm afraid I can't quite reproduce the problem. Maybe something changed in my configuration since I had the problem, or maybe I misinterpreted the problem to begin with. I did find an example where the formatting seems to fail, but it's not affected by the REPL. It seems that many (or all?) code samples involving The simplest example I found where the formatting fails is the following. Suppose we start with the following code consisting of two lines, one of which is empty:
Place the cursor at the top line and write (f
1) The second line has been indented. This result is as expected. Now we try the same but replacing
After typing (f
##Inf) The second line has not been indented, which is not as expected. This is the simplest example I could think of, but the presence of (let [[time id] (->> (range init-time ##Inf)
(some time-id-now))]
(println (* (- time init-time) id)))
(let [start 0
[max-i max-id] (apply max-key second ids)
offset (+ max-i (rem start max-id))]
(->> (range (- start offset) max-id)
(filter all-ordered?)
(first)
(println))) If I place my cursor right after the (let [[time id] (->> (range init-time ##Inf)
(some time-id-now))]
(println (* (- time init-time) id)))
(let [start 0
[max-i max-id] (apply max-key second ids)
offset (+ max-i (rem start max-id))]
(->>
(range (- start offset) max-id)
(filter all-ordered?)
(first)
(println))) This is not as expected. The elements below (let [start 0
[max-i max-id] (apply max-key second ids)
offset (+ max-i (rem start max-id))]
(->>
(range (- start offset) max-id)
(filter all-ordered?)
(first)
(println))) That's what I have so far. As I said this doesn't seem to be linked to the REPL. It could be that earlier I was conflating my experiments with Thanks again for your patience and I'm curious to hear your feedback about this. |
Thanks for the detailed examples! Let's see what @PEZ has to say about this. It does seem that |
Glad the mysterious behaviour went away, @MareinK. That looks like this issue with I renamed this issue and suggest we keep it open a while so that people who stumble across the problem can find it. |
I didn't see this rename, so I renamed 😄. Hope it's what was intended. |
I'm just starting out with Clojure/Calva/REPL-based-dev. I've managed to connect to the REPL and evaluate forms. However, after connecting to the REPL, my code is no longer formatted as I type, whereas it was being formatted before connecting. I've tried both the Jack-In option and starting my own REPL and connecting to the port, both with the same result. I'm not seeing any errors in the outputs. I'm not sure where to go from here, any help would be appreciated!
edit: I am now also getting an error pop up "Running the contributed command: 'calva-fmt.formatCurrentForm' failed." when I try to tab-indent a section of code, which I believe was not the case before I started experimenting with the REPL. The auto-formatting while coding is also less sophisticated than it was before I started experimenting with the REPL (even when not connected to a REPL now). It seems the experiments have broken something in my configuration, even though I don't think I explicitly changed any settings. I've tried reinstalling Calva and rebooting, to no avail.
VS code info:
Version: 1.51.1
Commit: e5a624b788d92b8d34d1392e4c4d9789406efe8f
Date: 2020-11-12T10:54:25.653Z
Electron: 9.3.5
Chrome: 83.0.4103.122
Node.js: 12.14.1
V8: 8.3.110.13-electron.0
OS: Linux x64 5.9.11-3-MANJARO
Calva version: v2.0.134
The text was updated successfully, but these errors were encountered: