parinfer / parinfer.js

Let's simplify the way we write Lisp
https://shaunlebron.github.io/parinfer
MIT License
1.76k stars 40 forks source link

Parinfer breaks valid code #112

Closed cursive-ide closed 8 years ago

cursive-ide commented 8 years ago

I haven't had time to debug why this happens, but a Cursive user reported the following case:

Before:

(defn about-page []
  (let [center-x 100
        center-y 100
        avatar "logo.jpg"
        u "clip"]
    [:div
     [:p (str "A long line of text ")]
     [:g {"dangerouslySetInnerHTML"
         #js{:__html (str "<image x=\"" (- center-x 28) "\" y=\"" (- center-y 28)  "\" width=\"56\" height=\"56\"
         xlink:href=\"assets/img/avatars/" avatar "\" style=\"clip-path: url(#" u "-clipPath)\" />")}}]]))

After:

(defn about-page []
  (let [center-x 100
        center-y 100
        avatar "logo.jpg"
        u "clip"]
    [:div
     [:p (str "A long line of text ")]
     [:g {"dangerouslySetInnerHTML"
         #js{:__html (str "<image x=\"" (- center-x 28) "\" y=\"" (- center-y 28)  "\" width=\"56\" height=\"56\"
         xlink:href=\"assets/img/avatars/" avatar "\" style=\"clip-path: url(#" u "-clipPath)\" />"))}}]]))
                                                                                                    ^
; parinfer added an extra ')'-----------------------------------------------------------------------|

I've verified that this also occurs in the demo editor, so it seems to be a bug in parinfer itself.

shaunlebron commented 8 years ago

Thanks, Colin, definitely a bug. A minimal example:

() "
"

Running Indent Mode will produce:

() "
")

Looking into it.

shaunlebron commented 8 years ago

@cursive-ide fix can be found in this commit: https://github.com/shaunlebron/parinfer/commit/a56c8d5f5b3a1bbc98e95013c2eb0df88e2be671

published in 1.8.1

cursive-ide commented 8 years ago

@shaunlebron Great, thanks!