mirror of
https://github.com/pcottle/learnGitBranching.git
synced 2025-07-07 21:24:26 +02:00
Resolves #378 -- only push state when commands count
This commit is contained in:
parent
7bfe56570c
commit
abf4d157b9
1 changed files with 21 additions and 4 deletions
|
@ -380,10 +380,29 @@ var Level = Sandbox.extend({
|
|||
Level.__super__.undo.apply(this, arguments);
|
||||
},
|
||||
|
||||
beforeCommandCB: function(command) {
|
||||
// Alright we actually no-op this in the level subclass
|
||||
// so we can tell if the command counted or not... kinda :P
|
||||
// We have to save the state in this method since the git
|
||||
// engine will change by the time afterCommandCB runs
|
||||
this._treeBeforeCommand = this.mainVis.gitEngine.printTree();
|
||||
},
|
||||
|
||||
afterCommandCB: function(command) {
|
||||
if (this.doesCommandCountTowardsTotal(command)) {
|
||||
// Count it as a command AND...
|
||||
this.gitCommandsIssued.push(command.get('rawStr'));
|
||||
// add our state for undo since our undo pops a command.
|
||||
//
|
||||
// Ugly inheritance overriding on private implementations ahead!
|
||||
this.undoStack.push(this._treeBeforeCommand);
|
||||
}
|
||||
},
|
||||
|
||||
doesCommandCountTowardsTotal: function(command) {
|
||||
if (command.get('error')) {
|
||||
// dont count errors towards our count
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
var matched = false;
|
||||
|
@ -392,9 +411,7 @@ var Level = Sandbox.extend({
|
|||
matched = matched || regex.test(command.get('rawStr'));
|
||||
});
|
||||
});
|
||||
if (matched) {
|
||||
this.gitCommandsIssued.push(command.get('rawStr'));
|
||||
}
|
||||
return matched;
|
||||
},
|
||||
|
||||
afterCommandDefer: function(defer, command) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue