Fork me on GitHub
#parinfer
<
2019-01-09
>
shaunlebron21:01:25

@cfleming interesting, smart mode should handle that well, but again it’s probably the editor integration that isn’t notifying parinfer of the nature of the change to help it do the right thing

cfleming21:01:20

I don’t think it’s that, it’s that IntelliJ sometimes produces very complex lists of overlapping changes.

shaunlebron21:01:52

ah, that’s actually what I meant

shaunlebron21:01:12

i’ll have to talk about state of parinfer on sunday for the repl podcast, maybe we can catch up on how it’s been working in cursive before then?

❤️ 5
👍 5
cfleming21:01:53

We’ve talked about this before, and IIRC the conclusion at the time was “it can’t be expected to handle all the potential edge cases for changes like that”, which I think is reasonable.

cfleming21:01:06

Sure, that sounds good.

shaunlebron21:01:03

i caught up with chris (atom) and jason (vim/kakoune) and they said the exact same thing about the editor integrations they’re maintaining

shaunlebron21:01:50

resorting to diffs for the changes they need

shaunlebron21:01:57

but only a partial solution

cfleming21:01:04

So what really made the difference was the change I made which doesn’t run paren mode on file open, but marks the problems instead and lets the user fix them.

cfleming21:01:57

Then it doesn’t matter if parinfer breaks something in a really crazy change list because the user can then fix it to what they meant.

shaunlebron21:01:02

because the breaking change is isolated to a single function?

cfleming21:01:25

No, a change may span various functions.

cfleming21:01:36

But at least it’s clearly marked where the problems are.

shaunlebron21:01:42

i suppose there’s different kinds of problems to think about

shaunlebron21:01:53

but you’re marking incorrect indentation

shaunlebron21:01:02

and not running indent/smart mode there

shaunlebron21:01:32

other problems are related to unexpected changes to code with previously correct indentation

cfleming21:01:07

Currently I don’t run it anywhere, so if the file is broken it’s broken, and there’s no parinfer until it’s fixed. I was planning to make a change to have that apply per top-level form, but I never got around to it and no-one has complained that it’s a problem.

shaunlebron21:01:11

i see, yeah i assumed the top-level form isolation was part of it

shaunlebron21:01:29

is smart mode on by default?

shaunlebron21:01:34

and are many using it?

shaunlebron21:01:44

and how’s the feedback?

shaunlebron21:01:56

(smart mode hidden by flag in atom, but feedback has been nil)

cfleming21:01:39

It’s actually not on by default, I meant to turn it on by default once it stabilised but never did. When I first brought it out a lot of people said they were using it and liking it, and I see occasional comments along those lines.

cfleming21:01:54

I don’t do any tracking though so I don’t have any firm numbers.

shaunlebron21:01:45

interesting, i suppose silence can be interpreted either way there

shaunlebron21:01:39

alright, I think that’s all I need to know for giving an update

shaunlebron21:01:50

thanks for pinging me on this

cfleming21:01:00

Generally, I’m super happy with it, and I use it all day myself.

cfleming21:01:20

The integration was one of the most painful things I’ve done in Cursive, though.

cfleming21:01:35

lein will always take top spot there, but this was probably second.

shaunlebron21:01:06

haha, alright, i expected as much, i remember how that was going last year

shaunlebron21:01:28

that might’ve been two years ago, idk anymore

cfleming21:01:40

A year or so, I think.

shaunlebron21:01:09

is that a common thing, and is that alright in parinfer?

cfleming21:01:29

Copy/paste is still a little painful sometimes. I have plans to make it better, but haven’t had time.

cfleming21:01:42

It’s definitely a common thing, and mostly works ok.

cfleming21:01:00

It’s complicated by the fact that IntelliJ likes to auto-indent pasted blocks.

cfleming21:01:44

Which happens before parinfer gets to run. That occasionally leads to things you wouldn’t expect, but they’re generally easy issues to fix.

shaunlebron21:01:12

yeah, i had weird things happen when doing some cljs work in atom, like it would dedent entire expressions after my cursor that i had to manually fix

shaunlebron21:01:38

never isolated the cause, but the root of this is that it is very delicate to the wrong change information from the editor

cfleming21:01:20

I don’t think that’s always the cause, sometimes it makes sense if you think about it, but to a user who doesn’t understand the algorithm it’s going to be weird.

cfleming21:01:47

e.g. if your editor looks like this:

(defn foo [bar])
  |

shaunlebron21:01:48

there’s that, yeah

cfleming21:01:28

i.e. you’ve started a new function, and you want to paste the body

cfleming21:01:07

Pasting there in Cursive will result in:

(defn foo [bar])
(your pasted form)|

cfleming21:01:20

The user will have expected it to be inserted in the defn form, because their caret was indented when pasting. But IntelliJ pastes, then indents, and then at the end parinfer is run. The indent sees that the new block is outside the top-level form so it dedents it, and then parinfer doesn’t put it in because it’s no longer where the user thought they put it.

shaunlebron21:01:38

right, editor interference

shaunlebron21:01:42

@eraserhd how do i pronounce your last name? just wanna get that right

cfleming21:01:03

Right, but there’s no step there which is obviously wrong, but the end result is confusing.

eraserhd22:01:20

btw, Kakoune apparently has almost exactly the change log we want, but it wasn't exposed. It wasn't the undo tree, but a monotonic change log that even records switches between branches of the undo tree.

eraserhd22:01:09

Monotonic is probably the wrong word. Append-only. I will attempt to use it this week.

shaunlebron22:01:04

huh, interesting, i’d be interested to see how that plays out

shaunlebron22:01:37

e.g. i wonder if types of changes will have to be ignored or not

eraserhd22:01:53

Well, there's two things to account for. The first is that this change log has only positional changes, not text. Internally, parinfer only needs positional changes, but it parses that out of text. So I'll need to change that somehow.

eraserhd22:01:21

(I mean start and end line and column.)

eraserhd22:01:49

The second is that parinfer wants changes as though they all happened simultaneously, and Kakoune's log has them stacked sequentially.

eraserhd22:01:38

e.g. the log might say "insert 10 characters at position 2, then delete 3 at position 7"

eraserhd22:01:14

so I'll need to flatten them

pez22:01:26

@shaunlebron About the state of integration. For Calva I have so far fallen back on only doing parinfer (smart mode) on the user’s command. Main reason being that vscode is a bit lacking in its API:s. But we have started a change in the whole formatting approach in Calva that might open up for on-the-fly parinfer.

💯 5
shaunlebron22:01:28

you mean running parinfer to format the file when the command is run for it?

pez22:01:41

Yes, Calva has a command Infer parens. (Since it has an on-the-fly formatter, things are most often correctly indented, so running smart mode means infer parens.)

shaunlebron22:01:49

so it’s a one time run, not a toggle to run continuously thereafter

shaunlebron22:01:22

if that’s the case, that smart mode = indent mode. the only thing that would make their effects different is the presence of the “changes” option

pez22:01:34

Yes, one-off, not a toggle. And no changes passed. But there there are two other commands that use that option (also on-offs).

eraserhd22:01:28

or "squish" them, or whatever that operation should be called.

metal 5
shaunlebron22:01:38

right, this sequential problem is seen in atom when we’re batching change events that can’t be fetched synchronously

shaunlebron22:01:57

chris wrote some code to “merge” these change objects together in vscode

pez22:01:00

(But so far the users who have talked to me about it are happy with doing smart mode at will.)

shaunlebron22:01:39

just to be precise with the language here, your integration is just using “indent mode” if no changes object is being passed to “smart mode”

pez22:01:47

Yes, so that’s the Infer parens command. There are also two commands that use the changes object, but they are doing it in a way that essentially makes it “paren mode”.