mirror of
https://github.com/pcottle/learnGitBranching.git
synced 2025-06-27 08:28:50 +02:00
updated undo command to only track when a command changes the tree
This commit is contained in:
parent
a0a6e922cb
commit
6258ed501e
1 changed files with 12 additions and 2 deletions
|
@ -67,7 +67,8 @@ var Sandbox = Backbone.View.extend({
|
||||||
|
|
||||||
initGitShim: function(options) {
|
initGitShim: function(options) {
|
||||||
this.gitShim = new GitShim({
|
this.gitShim = new GitShim({
|
||||||
beforeCB: this.beforeCommandCB.bind(this)
|
beforeCB: this.beforeCommandCB.bind(this),
|
||||||
|
afterCB: this.afterCommandCB.bind(this)
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -113,12 +114,21 @@ var Sandbox = Backbone.View.extend({
|
||||||
},
|
},
|
||||||
|
|
||||||
beforeCommandCB: function(command) {
|
beforeCommandCB: function(command) {
|
||||||
|
this._treeBeforeCommand = this.mainVis.gitEngine.printTree();
|
||||||
|
},
|
||||||
|
|
||||||
|
afterCommandCB: function(command) {
|
||||||
this.pushUndo();
|
this.pushUndo();
|
||||||
},
|
},
|
||||||
|
|
||||||
pushUndo: function() {
|
pushUndo: function() {
|
||||||
|
let currentTree = this.mainVis.gitEngine.printTree();
|
||||||
|
if(currentTree === this._treeBeforeCommand) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// go ahead and push the three onto the stack
|
// go ahead and push the three onto the stack
|
||||||
this.undoStack.push(this.mainVis.gitEngine.printTree());
|
this.undoStack.push(this._treeBeforeCommand);
|
||||||
},
|
},
|
||||||
|
|
||||||
undo: function(command, deferred) {
|
undo: function(command, deferred) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue