@hereugo/open-collaboration-monaco 0.4.1 → 0.4.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hereugo/open-collaboration-monaco",
3
- "version": "0.4.1",
3
+ "version": "0.4.2",
4
4
  "license": "MIT",
5
5
  "description": "Connect a single Monaco Editor to an Open Collaboration Tools session",
6
6
  "files": [
@@ -515,6 +515,10 @@ export class CollaborationInstance implements Disposable {
515
515
 
516
516
  const resyncThrottle = this.getOrCreateThrottle(path, document);
517
517
  const observer = (textEvent: Y.YTextEvent) => {
518
+ if (textEvent.transaction.local) {
519
+ // Local changes already updated the model; avoid re-applying and shifting offsets.
520
+ return;
521
+ }
518
522
  this.yjsMutex(async () => {
519
523
  if (this.options.editor) {
520
524
  const changes = YTextChangeDelta.toChanges(textEvent.delta);
@@ -529,9 +533,11 @@ export class CollaborationInstance implements Disposable {
529
533
  }
530
534
 
531
535
  protected updateDocument(document: monaco.editor.ITextModel, edits: monaco.editor.IIdentifiedSingleEditOperation[]): void {
536
+ this.stopPropagation = true;
532
537
  document.pushStackElement();
533
538
  document.pushEditOperations(null, edits, () => null);
534
539
  document.pushStackElement();
540
+ this.stopPropagation = false;
535
541
  }
536
542
 
537
543
  private createEditsFromTextEvent(changes: YTextChange[], document: monaco.editor.ITextModel): monaco.editor.IIdentifiedSingleEditOperation[] {