Przeglądaj źródła

Try lowering the save duration

Steven Silvester 7 lat temu
rodzic
commit
2b59a3424d

+ 2 - 1
packages/docmanager/src/savehandler.ts

@@ -199,7 +199,7 @@ class SaveHandler implements IDisposable {
       }
       let duration = new Date().getTime() - start;
       // New save interval: higher of 10x save duration or min interval.
-      this._interval = Math.max(10 * duration, this._minInterval);
+      this._interval = Math.max(this._multiplier * duration, this._minInterval);
       // Restart the update to pick up the new interval.
       this._setTimer();
     });
@@ -214,6 +214,7 @@ class SaveHandler implements IDisposable {
   private _isActive = false;
   private _inDialog = false;
   private _isDisposed = false;
+  private _multiplier = 10;
 }
 
 

+ 16 - 14
test/src/docmanager/savehandler.spec.ts

@@ -112,23 +112,25 @@ describe('docregistry/savehandler', () => {
 
     describe('#start()', () => {
 
-    //   it('should start the save handler', () => {
-    //     handler.start();
-    //     expect(handler.isActive).to.be(true);
-    //   });
-
-    //   it('should trigger a save', (done) => {
-    //     context.fileChanged.connect(() => {
-    //       done();
-    //     });
-    //     context.model.fromString('bar');
-    //     expect(handler.isActive).to.be(false);
-    //     handler.saveInterval = 1;
-    //     handler.start();
-    //   });
+      it('should start the save handler', () => {
+        handler.start();
+        expect(handler.isActive).to.be(true);
+      });
+
+      it('should trigger a save', (done) => {
+        context.fileChanged.connect(() => {
+          done();
+        });
+        context.model.fromString('bar');
+        expect(handler.isActive).to.be(false);
+        handler.saveInterval = 1;
+        handler.start();
+      });
 
       it('should continue to save', (done) => {
         let called = 0;
+        // Lower the duration multiplier.
+        (handler as any)._multiplier = 1;
         console.log('\n\n\n***continue to save')
         context.fileChanged.connect(() => {
           console.log('***called', called);