Fork me on GitHub
#parinfer
<
2017-08-30
>
cfleming00:08:20

Here’s another interesting problem:

(defn empty-panel [text]
  (let [status-text (extend-class StatusText []
                      (isStatusVisible [this] true))
        panel (extend-class JPanel []
                (paintComponent [this g]
                  (.paintComponent ^JPanel this ^Graphics g)
                  (.paint status-text this g)))]
    (doto status-text
      (.attachTo panel)
      (.setText text))
    panel))

cfleming00:08:04

I then rename panel, and start typing a totally new name, so I press delete and then start typing.

cfleming00:08:43

When I do that, the panel in (.attachTo panel) disappears, and parinfer deletes the space in there.

cfleming00:08:06

And when I confirm the new name, I get something like (.attachTonew-name)

cfleming00:08:40

I need to be able to supply extra holding locations, I guess.

cfleming00:08:09

I think that will be ok, since I have already modified my version to accept multiple carets. I haven’t tested the edge cases with that yet though.

cfleming00:08:52

I suspect it will be weird if you have the same file open in multiple editors and are editing a line that the caret is on in another editor.

cfleming00:08:57

The holding stuff really complicates the integration though.

cfleming00:08:11

I can’t think of a good alternative but it’s tricky.

shaunlebron00:08:35

i’m not understanding how the rename operation happens

shaunlebron00:08:16

might be easier to diagnose this problem with a list of changes that the rename operation produces

cfleming02:08:11

@shaunlebron Let me record a video

cfleming03:08:17

Watch what happens to the .attachTo near the bottom.

cfleming03:08:58

The issue is that the symbol to be renamed is deleted temporarily if I delete the whole name, and the paren isn’t held because the caret isn’t there.

cfleming03:08:17

I think I can create some extra hold locations from the template positions during the rename.

cfleming03:08:26

I’m not sure if they should participate in the hold release mechanism or not - probably, I guess.

cfleming03:08:49

i.e. they’ll be basically just like caret positions that don’t have a previous position.

cfleming03:08:07

Actually, perhaps they could have a previous position, and I’ll pretend there is a caret inside each template location at the same offset as the actual caret is within its template location.

cfleming03:08:20

(the “templates” here are all the points where the inline rename happens)

shaunlebron03:08:08

yeah, if you already have multiple cursor support, it should work by placing a cursor at the end of each template

cfleming03:08:36

I’ll check the API to see how easy that is.

shaunlebron03:08:58

nice gif! should be easier to communicate these subtleties now

cfleming03:08:19

@shaunlebron That works a treat

cfleming03:08:40

You can see the parens being held both near count and at the end of the form.

shaunlebron03:08:18

very cool, i noticed the ) being held at last line

shaunlebron03:08:34

i take it you’re not using forceBalance?

cfleming04:08:19

No, I’m not.

cfleming04:08:29

I haven’t ported your recent changes yet.

cfleming04:08:32

Thinking about it, I should create those carets for the indentation check as well.

cfleming04:08:11

I can’t think of a situation when that might affect the indentation, but I’m sure there are plenty of weird edge cases I haven’t thought of.

shaunlebron04:08:22

well i’m only recommending forceBalance: false

shaunlebron04:08:48

if it’s enabled, it doesn’t support ) being on its own line