From 274b8289ef222d2641b124b6f9c55c63b27af7bb Mon Sep 17 00:00:00 2001 From: =?utf8?q?Aleksander=20=C5=81ukasz?= Date: Sat, 7 Dec 2013 22:34:12 +0100 Subject: [PATCH] smartxml: fix - do not clear redo stack if we are just performing undo operation --- src/smartxml/smartxml.js | 4 +++- src/smartxml/smartxml.test.js | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+), 1 deletion(-) 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() { -- 2.20.1