parinfer

pez 2019-11-07T08:09:55.003200Z

Hello. Can someone, in the know, make a brief description on what it is that makes smartmode so hard to implement in vscode? I have been using Calva’s Clojure parser/editor/document mirror a bit the last days, and I think it might be possible for Calva to expose an API to it, which might help. But since I don’t know what the problem is, I might just be wrong about Calva being able to help.

mkvlr 2019-11-07T09:50:51.003700Z

@pez if podcasts are your thing, Shaun talked about it in https://soundcloud.com/user-959992602/s2-e1-lisp-editing-with-shaun-lebron IIRC

pez 2019-11-07T09:58:55.004300Z

Podcasts are my thing. Especially that podcast!

pez 2019-11-07T09:59:33.005100Z

However, I have listened to the episode, and I still would need the actual problem in VS Code spelled out.

henrik 2019-11-07T19:01:22.007600Z

My memory is very hazy. I remember vaguely something to do about needing to grab control of the global buffer state and not being able to, and something about the nature of events firing and the context available in those events.

henrik 2019-11-07T19:02:49.008200Z

It was some time since anyone took a crack at it I think, VSCode might have changed since.

mattly 2019-11-07T20:59:10.008900Z

IIRC there’s also a longstanding issue with VSCode Vim that’s reliant on the same issue

pez 2019-11-07T21:38:07.009800Z

@henrik: VSCode hasn’t change in this aspect, I am pretty sure.

cfleming 2019-11-07T21:38:16.010100Z

My understanding is also hazy, but I believe it was because document update events are asynchronous, and smart mode assumes synchronous updates.

cfleming 2019-11-07T21:39:25.010700Z

@chrisoakman may remember more details, IIRC he was the one who worked on it.

pez 2019-11-07T21:43:43.012300Z

That’s similar to what I recall. But also that the events lacked information about what had happened… but that could have been me just misunderstanding.

cfleming 2019-11-07T21:55:43.013200Z

FWIW integrating smart mode was one of the hardest things I’ve ever had to do in Cursive. I wrote up a brain dump about it here:

cfleming 2019-11-07T21:56:15.014Z

I don’t know how much of that applies to VS Code but some of it might, in particular since it supports project-wide refactorings via the LSP

cfleming 2019-11-07T21:58:25.015100Z

In general, once an editor moves away from the “a user edits a single file, the changes to that file come from the user typing” model, smart mode gets very hard to integrate.

cfleming 2019-11-07T21:58:31.015300Z

@pez ^^

cfleming 2019-11-07T21:59:57.015800Z

I also had to modify parinfer to correctly handle multiple carets

pez 2019-11-07T22:49:57.016400Z

Thanks @cfleming! It seems pretty hairy, actually. 😃

cfleming 2019-11-07T23:04:03.016700Z

It is extremely hairy 🙂

cfleming 2019-11-07T23:04:16.017100Z

I’m just hoping that I never have to touch that code again 😉