2 ms·
I think it would be interesting to approach this from the language mode side, insisting on structured buffers (syntax tree with rope leaves†). It is pretty rare
by microcolonel 6y ago
I think it would be interesting to approach this from the language mode side, insisting on structured buffers (syntax tree with rope leaves†). It is pretty rare that two clients (mode and user window, or two user windows) would lock a single large leaf, so you could just choose an authority/leader for each subtree, and have the leader explicitly and synchronously sequence the peon clients' edits.
Then, working backward from language specific modes, I could imagine a way to generalize this to free form text, by negotiating the split points with the authority (or not at all, in the case of free text being edited by one client).
Though I guess for now just making these completely synchronous across the whole buffer, as you have, is fine in most cases, and already a significant improvement vs some editors (looking at you, beloved Emacs).
† i.e. for js, you could imagine a tree of statements/blocks containing expressions (maybe incl. operator precedence); for Clojure you could imagine a plain syntax tree, for JSON you could imagine it being the literal JSON data (plus whitespace metadata).