Răsfoiți Sursa

Merge pull request #2041 from overleaf/bg-enforce-consistency-check

enforce consistency check for editors

GitOrigin-RevId: 2b8abed4519476be52563cbfecb799858f6dad0c
Brian Gough 7 ani în urmă
părinte
comite
8237319683

+ 2 - 0
services/web/public/js/libs/sharejs.js

@@ -1505,6 +1505,7 @@ define(['ace/ace','libs/sha1'], function () {
         var otText = doc.getText();
 
         if (editorText !== otText) {
+          doc.emit('error','Text does not match in ace')
           console.error('Text does not match!');
           console.error('editor: ' + editorText);
           return console.error('ot:     ' + otText);
@@ -1665,6 +1666,7 @@ define(['ace/ace','libs/sha1'], function () {
         var otText = sharedoc.getText();
 
         if (editorText !== otText) {
+          sharedoc.emit('error','Text does not match in CodeMirror')
           console.error('Text does not match!');
           console.error('editor: ' + editorText);
           return console.error('ot:     ' + otText);

+ 0 - 7
services/web/public/src/ide/editor/Document.js

@@ -97,7 +97,6 @@ define([
           this.ace
         )
         this._checkCMConsistency = _.bind(this._checkConsistency, this, this.cm)
-        this.inconsistentCount = 0
         this._bindToEditorEvents()
         this._bindToSocketEvents()
       }
@@ -161,12 +160,6 @@ define([
             const sharejsValue =
               this.doc != null ? this.doc.getSnapshot() : undefined
             if (editorValue !== sharejsValue) {
-              this.inconsistentCount++
-            } else {
-              this.inconsistentCount = 0
-            }
-
-            if (this.inconsistentCount >= 3) {
               return this._onError(
                 new Error('Editor text does not match server text')
               )