Merge pull request #1087 from birdalicious/undo-update

updated undo command to only track when a command changes the tree
This commit is contained in:
Peter Cottle 2023-07-19 08:31:50 -06:00 committed by GitHub
commit c20f05952c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -67,7 +67,8 @@ var Sandbox = Backbone.View.extend({
initGitShim: function(options) {
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) {
this._treeBeforeCommand = this.mainVis.gitEngine.printTree();
},
afterCommandCB: function(command) {
this.pushUndo();
},
pushUndo: function() {
let currentTree = this.mainVis.gitEngine.printTree();
if(currentTree === this._treeBeforeCommand) {
return;
}
// 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) {