mizzao / meteor-sharejs

Meteor smart package for transparently adding ShareJS editors to an app
MIT License
225 stars 53 forks source link

Support multiple simultaneous CodeMirror edits #100

Open edemaine opened 5 years ago

edemaine commented 5 years ago

CodeMirror can stage multiple edits at once, for example, using multiple cursors (ctrl-click), or updating many numbers at once in Markdown, or hitting newline before some whitespace at the end of the line. These multiple updates need to be handled with care because of the way document indices (and number of lines / characters per line) changes during the course of the edits. The old code would cause the CodeMirror editor and ShareJS document to get out of sync; the new code fixes this problem. See this bug report.

I converted the code back to CoffeeScript, edited that, and compiled to produce new JavaScript. You can also see the CoffeeScript source code. This PR naturally includes #99 as well.

Users: Until this PR and my other PRs get merged, I'd recommend using my fork (meteor add edemaine:sharejs and meteor add edemaine:sharejs-codemirror) which includes all of my PRs.