y-text icon indicating copy to clipboard operation
y-text copied to clipboard

yText doesn't work properly with Monaco v0.10.0

Open NathanaelA opened this issue 7 years ago • 0 comments

There are at couple issues with the current version of Monaco and the current version of Y-JS. I finally had an opportunity to test this out and integrate it; and it doesn't work. ;-(

First The new version of Monaco changed the onDidChangeModelContent it now sends you an array of changes. So in monacoCallback, made a small change so that it would loop through the changes

function monacoCallback (orgEvent) { 
...
 for (var j=0;j<orgEvent.changes.length;j++) {
                  var event = orgEvent.changes[j];
...

No more exceptions Yay. (I think this fixes the obvious compatible issue)

I tested initially on a TextArea which works great with the following design:

  1. Server creates a new Workspace with Share.files = Map. (i.e. ymap)
  2. Client gets a message to attach to the Workspace, and connects (and waits for it).
  3. Client asks to open a file
  4. Server creates new YText's inside the files Map.
  5. Client gets a message to attach to a file in the editor and uses:
  • Removed any existing binding and creates a new Monaco Model, and attaches it as the current monaco model. The text is transferred in the inital attach message (outside of YJS), because Y can sometimes be slow... Then it proceeds to do: yWorkspace.connector.whenSynced which works about 33% of the time to have the file YText is ready, but if it fails here; I waits for the y.share.files.observe add event and then attempts the same code path above with the whenSynced and catches the rest of the times. At this point I am able to get the files YText properly. And then I bind it to the actual editor. So far everything seems good. If I type I see events occur on the server, clients, etc. BUT the attached editors never change their content. ;-(

If I use a pure TextArea, this seems to work fine. If I create a demo Monaco project using the "Monaco" as the share; it partially works; one browser will update the other browser; but the other browser will NOT updated the other one. So it posts updates through the exact same server process...

So in summary:

  1. Using YMap -> Multiple YTexts; does NOT update any browsers on changes, but attaching to the events, I see update and sync messages; so it "appears" that it is sending things between the browser, just not updating Monaco.
  2. Using YText directly, appears to keep one Monaco instance in one browser updated; the other browser does not update.
  3. Using YText or YMap->YText in textarea seems to work great.

I based this off the default YSocket examples; other than the changes to make it used Map's. All sides are using the YMemory storage. I was really hoping to present this project on the 19th; but at this point I'm not going to be able to use YJS to sync things as much as I would love to.. If you have any thoughts, I'll be watching this issue religiously. :)

NathanaelA avatar Sep 16 '17 19:09 NathanaelA