From: Aleksander Ɓukasz Date: Sat, 7 Dec 2013 21:34:12 +0000 (+0100) Subject: smartxml: fix - do not clear redo stack if we are just performing undo operation X-Git-Url: https://git.mdrn.pl/fnpeditor.git/commitdiff_plain/274b8289ef222d2641b124b6f9c55c63b27af7bb smartxml: fix - do not clear redo stack if we are just performing undo operation --- diff --git a/src/smartxml/smartxml.js b/src/smartxml/smartxml.js index d722c20..eb97ea9 100644 --- a/src/smartxml/smartxml.js +++ b/src/smartxml/smartxml.js @@ -436,7 +436,9 @@ $.extend(Document.prototype, Backbone.Events, { } this._transformationLevel--; //console.log('clearing redo stack'); - this.redoStack = []; + if(!this._undoInProgress) { + this.redoStack = []; + } return toret; } else { throw new Error('Transformation ' + transformation + ' doesn\'t exist!'); diff --git a/src/smartxml/smartxml.test.js b/src/smartxml/smartxml.test.js index 3ee2793..991f1af 100644 --- a/src/smartxml/smartxml.test.js +++ b/src/smartxml/smartxml.test.js @@ -1023,7 +1023,41 @@ describe('smartxml', function() { doc.undo(); expect(doc.undoStack).to.have.length(0, '5'); expect(doc.toXML()).to.equal('
Alice
'); + }); + + it('smoke tests 2', function() { + var doc = getDocumentFromXML('
Alice
'), + textNode = doc.root.contents()[0], + path = textNode.getPath(), + result; + + debugger; + textNode.setText('Alice '); + textNode.setText('Alice h'); + textNode.setText('Alice ha'); + textNode.setText('Alice has'); + + expect(textNode.getText()).to.equal('Alice has'); + + doc.undo(); + expect(doc.root.contents()[0].getText()).to.equal('Alice ha', '1'); + doc.undo(); + expect(doc.root.contents()[0].getText()).to.equal('Alice h', '2'); + + doc.redo(); + expect(doc.root.contents()[0].getText()).to.equal('Alice ha', '3'); + + doc.redo(); + expect(doc.root.contents()[0].getText()).to.equal('Alice has', '4'); + + doc.undo(); + doc.undo(); + textNode = doc.getNodeByPath(path); + textNode.setText('Cat'); + doc.undo(); + textNode = doc.getNodeByPath(path); + expect(textNode.getText()).to.equal('Alice h'); }); // it('does work', function() {