This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2016-02-22
Channels
- # aatree (2)
- # beginners (14)
- # boot (190)
- # cider (16)
- # cljs-dev (15)
- # cljsjs (6)
- # cljsrn (7)
- # clojure (101)
- # clojure-austin (26)
- # clojure-berlin (2)
- # clojure-estonia (4)
- # clojure-greece (53)
- # clojure-russia (46)
- # clojurescript (44)
- # core-async (12)
- # cursive (57)
- # data-science (49)
- # datomic (5)
- # emacs (8)
- # hoplon (92)
- # ldnclj (20)
- # lein-figwheel (22)
- # leiningen (4)
- # mount (37)
- # om (103)
- # onyx (26)
- # parinfer (70)
- # proton (6)
- # re-frame (32)
- # reagent (1)
- # yada (24)
@cfleming, yeah chris and I paired this afternoon to fix the selection issue you mentioned
when a selection is made, or if there are multiple cursors, atom-parinfer will not update the cursor position for you
https://github.com/oakmac/atom-parinfer/blob/master/src-cljs/atom_parinfer/core.cljs#L277-L282
@shaunlebron: Ok, thanks.
I’m just playing around with the idea of creating deltas instead of updating the lines in place - then the algorithm can be run in one pass over the original document, and the user could call a function to get new text with the deltas applied, or choose to receive the deltas.
Most editors won’t store the text as a single contiguous string, so applying small deltas will probably be more efficient.
If the change gets too tricky, I’ll just use the existing algorithm for now since I should get a release out sometime soon.
character-based diffs?
a nice property of parinfer is that it will never add or remove lines, just modifies existing ones
so that’s why the line-based deltas are so straightforward, i’m returning changedLines
Yeah, I saw that. Perhaps I’ll just use that to start since that’s (relatively) minimal.
just trying to understand what the delta change looks like, or what it’s doing
so instead of modifying the line in result.lines[i]
, you’re doing something else?
Right. Instead of scanning by line, I scan once over the whole text without splitting it into lines. I do the line bookkeeping when I see a \n
I’m worried about the garbage being created on every call to parinfer by taking the document and splitting it into lines.
On the JVM that used to re-use the same character array, but it now copies it instead.
i think that’s feasible
the last version changed removeParenTrail
it used to remove the paren trail after processing every line
it’s now just popParenTrail
, modifies the paren stack
It would also mean that you wouldn’t need the getLineEnding thing to re-join the lines.
anyway, no unnecessary modifications, and you can watch all line modifications at replaceWithinLine
function
interesting
And it is probably feasible to apply the changes in whichever way is friendliest to the JS garbage collector.
I like this
I’m actually very impressed with how well V8 handles all the string concatenation though.
Anyway, I’m hoping to have it working this afternoon with a bit of luck, and we can see if we like it at that stage.
As an aside, I’m using http://wallabyjs.com to make the change, it’s lovely.
was it slow when splitting lines?
I’m not sure. I don’t know whether the JS engines re-use the backing char array or not.
The JVM used to but then they changed it since apparently people would often hold onto small substrings of very large backing arrays, which caused memory problems.
But I’m not just thinking about memory pressure, I suspect that in practice applying diffs will be much better for performance in text editors, although I have no idea how to benchmark that.
i’m really liking the delta idea
are you trying this in parinfer.js first?
with wallaby somehow?
You’ll be pleased to hear that Wallaby shows great test coverage too, only a couple of edge cases not covered (tabs and \r\n
)
awesome, would love to try this
yeah, i sort of changed my testing philosophy in parinfer, just focusing on the core inference stuff
yeah, if you have time to share that
need to step out for an hour
awesome change btw if we can get that in
haha, i don’t mind that
i’ll be moving to parinfer soon anyway
atom*
@shaunlebron: Actually, one more advantage of the deltas is that you don’t actually need to track cursor or selection position - they’ll automatically be updated by the editor as the text is modified.
@cfleming: mind blown
lol, yeah, the editor should totally take care of that. way simpler
I had hoped that all edits would be applied to the document in source order, but that’s not the case.