parinfer

cfleming 2017-08-30T00:17:20.000090Z

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))

cfleming 2017-08-30T00:18:04.000201Z

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

cfleming 2017-08-30T00:18:43.000091Z

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

cfleming 2017-08-30T00:19:06.000217Z

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

cfleming 2017-08-30T00:19:40.000099Z

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

cfleming 2017-08-30T00:41:09.000148Z

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.

cfleming 2017-08-30T00:41:52.000113Z

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.

cfleming 2017-08-30T00:42:57.000237Z

The holding stuff really complicates the integration though.

cfleming 2017-08-30T00:43:11.000038Z

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

shaunlebron 2017-08-30T00:50:35.000174Z

i’m not understanding how the rename operation happens

shaunlebron 2017-08-30T00:51:16.000146Z

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

cfleming 2017-08-30T02:55:11.000079Z

@shaunlebron Let me record a video

cfleming 2017-08-30T03:01:17.000186Z

Watch what happens to the .attachTo near the bottom.

cfleming 2017-08-30T03:01:58.000045Z

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.

cfleming 2017-08-30T03:02:17.000061Z

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

cfleming 2017-08-30T03:03:26.000058Z

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

cfleming 2017-08-30T03:03:49.000048Z

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

cfleming 2017-08-30T03:06:07.000003Z

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.

cfleming 2017-08-30T03:06:20.000018Z

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

shaunlebron 2017-08-30T03:07:08.000115Z

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

cfleming 2017-08-30T03:07:24.000178Z

Right.

cfleming 2017-08-30T03:07:36.000017Z

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

shaunlebron 2017-08-30T03:28:58.000034Z

nice gif! should be easier to communicate these subtleties now

cfleming 2017-08-30T03:44:19.000039Z

@shaunlebron That works a treat

cfleming 2017-08-30T03:44:40.000096Z

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

shaunlebron 2017-08-30T03:58:18.000065Z

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

shaunlebron 2017-08-30T03:58:34.000078Z

i take it you’re not using forceBalance?

cfleming 2017-08-30T04:05:19.000221Z

No, I’m not.

cfleming 2017-08-30T04:05:29.000007Z

I haven’t ported your recent changes yet.

cfleming 2017-08-30T04:07:32.000116Z

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

cfleming 2017-08-30T04:08:11.000126Z

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.

shaunlebron 2017-08-30T04:14:22.000162Z

well i’m only recommending forceBalance: false

shaunlebron 2017-08-30T04:14:48.000098Z

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