Fork me on GitHub
#calva
<
2018-11-25
>
gradorsys09:11:24

I am just a silent listener. But I think it is necessary to step out of darkness and to let you know that your work is appreciated a lot. I also think it is a very import step in the right direction to make clojure more accessible for beginners. :thumbsup:

❤️ 8
8
pez09:11:45

@lilactown I just found two bugs with the enclosing? function. One is that it doesn’t disregard brackets inside strings, a rather tricky problem to solve, I imagine. So:

(enclosing? "(\"(\")") => false
Another is that it croaks when there is balance at the edges of the range, but unbalance within, but only if it is different kinds of brackets that are balanced/unbalanced. Hmmm, I did not explain that very good… Look at this:
(enclosing? "[)]") => Error: IllegalArgumentException Don't know how to create ISeq from: clojure.lang.Reduced  clojure.lang.RT.seqFrom (RT.java:550)

(enclosing? "[]]") => false

pez09:11:36

I’ll try to see if I can see how the latter can be fixed, but I need to start with adding a workaround for when it happens so that I can send out an intermediate fix asap. If you (or anyone else) have some time to look at it, I would love the help. The string issue is somewhat less urgent, but I would be happy to get ideas on how to tackle it. We have both paredit and that AST, after all…

pez10:11:34

I have updated the repo with tests that expose the above errors:

Testing calva.fmt.util-test

ERROR in (enclosing?) (Error:NaN:NaN)
expected: (= true (sut/enclosing? "([)"))
  actual: #object[Error Error: [object Object] is not ISeqable]

FAIL in (enclosing?) (cljs-runtime/cljs/test.cljs:475:6)
expected: (= true (sut/enclosing? "(\"(\")"))
  actual: (not (= true false))

pez11:11:19

That repo is here: https://github.com/BetterThanTomorrow/calva-fmt , if anyone wants to pack PRs.

pez11:11:00

Also filed two issues about it. Here’s the one about strings: https://github.com/BetterThanTomorrow/calva-fmt/issues/7

slipset11:11:44

@pez have you considered applying for a Clojurists Together grant?

slipset11:11:24

I know that for me such a grant doesn’t make sense, since I have a full time job and the grant isn’t big enough for me to afford taking a leave of absence.

pez11:11:03

@slipset This has been suggested at times. I am happy people think this project is so important. However, my work situation is such that right now is not a good time for applying.

pez11:11:48

I could probably afford it, sadly enough. 😃

slipset12:11:14

But I think Clojurists Together would be interested in finding ways to support smaller projects with smaller grants.

pez14:11:22

I have fixed the enclosing problem with brackets in strings and improved the situation with unbalanced expressions inside enclosing list types (returns false instead of croaking). It’s a bit of a Schrödinger’s fragment anyway, I am not sure if it should answer true or false.

pez14:11:47

My new enclosing? function looks like so:

(defn enclosing? [text]
  (let [ast (cljify (paredit/parse text))
        children (:children ast)]
    (and (= 1 (count children))
         (= "list" (:type (first children))))))

(comment
  (enclosing? "[][]") => false
  (enclosing? "([][])") => true
  (enclosing? "([)") => false
  (enclosing? "[\"[\"]") => true
  (enclosing? "(\"[\")") => true
  (enclosing? "\"foo\"") => false )

pez23:11:58

Exciting!

pez23:11:22

Here’s a mystery. Calva Formatter formats the contents of some strings. (It shouldn’t!) I’ve tried with versions from months back and they all do it, so it is nothing new. Here’s an example:

(comment
  "([\\])"
  "([\\]\\])"
  "([\\[\\]\\])")
Place the cursor right inside the first paren in the third string and press TAB (assuming default keybindings). It doesn’t happen in the first two strings.

pez23:11:45

It’s super late here, @marc-omorain, I’ll have a look at that PR tomorrow. 😃 Sounds good to use TS types to get some hold on the responses.

pez23:11:17

And, yes, I’d love to get that test view in place.