oakes / Nightcode

An IDE for Clojure
https://sekao.net/nightcode/
The Unlicense
1.4k stars 124 forks source link

Parens inserted incorrectly after deleting a line and won't reorder properly #214

Closed esuomi closed 7 years ago

esuomi commented 7 years ago

Steps to reproduce:

  1. Start with the following:

    (defn poof
      [a b]
      (apply f 
        (map b 
          (vector 1 2 3))))
  2. Delete the line (apply f character by character with the DEL key.
  3. Observe that at the same instant the character f is deleted, the params list closing bracket jumps to the pile-o-parens at the end and tries its best to stay there as seen below:

    (defn poof
      [a b
    
        (map b 
          (vector 1 2 3))])

There seems to be a few variants of this behaviour depending on how deeply nested the form is, mainly in how sticky the ] becomes.

oakes commented 7 years ago

This looks like correct behavior. Parinfer places delimiters based on indentation. To correct it, select the two bottom lines and hit shift+tab (I think you'll need to do this twice). By fixing the indentation, parinfer will automatically place the closing square bracket in the right spot.

oakes commented 7 years ago

Let me know if that explanation doesn't make sense.

esuomi commented 7 years ago

Hi,

Well, I suppose it is correct from semantical point of view but not from an IDE as developer utility point of view :) I figured something like that would be the cause though and also understand that fixing it would actually mean processing the AST and doing non-linear resolving similar to eg. Cursive and that might be a bit much as this is "just" Parinfer.

oakes commented 7 years ago

That is understandable. I am going to work on some modifications to parinfer's behavior in the future, and when doing so I'll consider this case.

esuomi commented 7 years ago

Sounds good to me 👍