Fork me on GitHub
#calva
<
2023-01-15
>
Jakub Holý (HolyJak)19:01:52

Dear Calva devs, thank you so much for “replace with pretty printed form”!

🙏 2
plus_one 2
❤️ 2
noob.clj19:01:56

Hey all, Is it possible to send multiple lines to REPL in VSCode? I have below code:

(def knight-awake? false)
(def archer-awake? true)
(def prisoner-awake? false)
If I select all three lines and press [Opt + Enter] it only sends the line on which my cursor is on.

pez19:01:15

Hi! The command for this is Calva: Evaluate Current Form (or selection, if any), default bound to ctrl+enter.

noob.clj19:01:47

I tried that, it still doesn’t work for me 😞 may be some plugin I have is interrupting it.

pez20:01:35

Did you try the command from the command palette, or the shortcut, or both?

pez20:01:58

What errors do you get?

skylize20:01:56

I have sometimes had mixed results from behavior of Evaluate Current Form. Not having spent any mental energy on the problem as of yet, I subconsciously hypothesized it is similar to the annoyance with Evaluate Current File (approximate name of command from memory) that any exception thrown seems to cause the entire eval to be discarded. Does that sound like a reasonable guess?

pez20:01:17

It doesn't sound reasonable for the example given. 😃

noob.clj20:01:16

Actually I don’t get any error. I tried both (command palette and keyboard shortcut) and it only evaluates last line.

pez21:01:14

It evaluates all code selected. It then only returns the result of the last expression. That's how Clojure works.

pez21:01:09

Evaluate the archer-awake? symbol (place your cursor in it and hit ctrl+enter), and you should see that that definition was evaluated.

noob.clj21:01:23

It is only evaluating the last one.

pez21:01:38

It really behaves as if you are evaluating the top level form. It should behave as in this video:

pez21:01:59

Evaluating top level form finds the top level form from the cursor (the last form, if the selection ends there) and evaluates that. Evaluate current form or selection, evaluates the selection if there is any, otherwise finds the current form and evaluates that. If this doesn't happen for you we have a bug. But not immediately reproducible by me at least.

noob.clj22:01:28

Ohhh it worked 🙂 super weird, I think it works with ctrl+enter and I tried opt + enter. Thanks a lot for your help 👍

🙏 2
pez22:01:38

You're welcome!

skylize00:01:40

> It then only returns the result of the last expression. > Printing intermediate results from each evaluated form (without needing to step the cursor through each) seems like a useful behavior. Something like Evaluate selected forms in sequence which would run Evaluate top level form individually for each form. I suspect this would make a fairly trivial Joyride script, but maybe worth considering for Calva?

pez00:01:15

Yeah, I think I'd use that. 😃