diff --git a/src/collections.js b/src/collections.js index a38d4b27..3413642c 100644 --- a/src/collections.js +++ b/src/collections.js @@ -33,12 +33,9 @@ var CommandBuffer = Backbone.Model.extend({ // processed. if it's not, we immediately process the first item // and then set the timeout. if (this.timeout) { - console.log('timeout exists abort'); // timeout existence implies its being processed return; } - console.log(this.timeout); - console.log('setting timeout'); this.setTimeout(); }, @@ -57,11 +54,13 @@ var CommandBuffer = Backbone.Model.extend({ // find a command with no error while (popped.get('error') && this.buffer.length) { - popped = buffer.pop(); + popped = this.buffer.pop(); } if (!popped.get('error')) { // pass in a callback, so when this command is "done" we will process the next. events.trigger('processCommand', popped, callback); + } else { + this.clear(); } }, diff --git a/src/commandline.js b/src/commandline.js index 66553990..2ddf7370 100644 --- a/src/commandline.js +++ b/src/commandline.js @@ -18,6 +18,7 @@ var Command = Backbone.Model.extend({ if (!this.get('createTime')) { this.set('createTime', new Date().toString()); } + this.on('change:error', this.errorChanged, this); }, initialize: function() { @@ -31,20 +32,25 @@ var Command = Backbone.Model.extend({ } catch (err) { if (err instanceof CommandProcessError || err instanceof GitError) { - this.formatError(err); this.set('status', 'error'); + this.set('error', err); } else if (err instanceof CommandResult) { - this.formatError(err); this.set('status', 'finished'); + this.set('error', err); } else { throw err; } } }, - formatError: function(err) { - this.set('error', err); - this.set('result', err.toResult()); + errorChanged: function(model, err) { + this.set('err', err); + this.set('status', 'error'); + this.formatError(); + }, + + formatError: function() { + this.set('result', this.get('err').toResult()); }, getShortcutMap: function() { diff --git a/src/git.js b/src/git.js index 944df9f3..e7a11f1a 100644 --- a/src/git.js +++ b/src/git.js @@ -692,7 +692,21 @@ GitEngine.prototype.dispatch = function(command, callback) { }); command.set('status', 'processing'); - this[command.get('method') + 'Starter'](); + try { + this[command.get('method') + 'Starter'](); + } catch (err) { + if (err instanceof GitError || + err instanceof CommandResult) { + + // short circuit animation by just setting error and returning + command.set('error', err); + callback(); + return; + + } else { + throw err; + } + } // TODO (get rid of) for (var i = 0; i < 3; i++) { diff --git a/src/mine.js b/src/mine.js index 47f6bb2a..99585289 100644 --- a/src/mine.js +++ b/src/mine.js @@ -36,6 +36,8 @@ $(document).ready(function(){ gitEngine = new GitEngine(); gitVisuals = new GitVisuals(); + + $('#commandTextField').focus(); }); diff --git a/src/views.js b/src/views.js index 8bd3e420..411dd25d 100644 --- a/src/views.js +++ b/src/views.js @@ -108,12 +108,16 @@ var CommandView = Backbone.View.extend({ }, wasChanged: function(model, changeEvent) { + console.log('command changed', model, changeEvent); // for changes that are just comestic, we actually only want to toggle classes // with jquery rather than brutally delete a html of HTML var changes = changeEvent.changes; var changeKeys = _.keys(changes); if (_.difference(changeKeys, ['status']) == 0) { this.updateStatus(); + } else if (_.difference(changeKeys, ['error']) == 0) { + // the above will + this.render(); } else { this.render(); } @@ -160,6 +164,8 @@ var CommandLineHistoryView = Backbone.View.extend({ this.collection.on('add', this.addOne, this); this.collection.on('reset', this.addAll, this); this.collection.on('all', this.render, this); + + this.collection.on('change', this.scrollDown, this); }, scrollDown: function() { diff --git a/src/visuals.js b/src/visuals.js index 7fb946d7..5ea8c122 100644 --- a/src/visuals.js +++ b/src/visuals.js @@ -7,7 +7,6 @@ function GitVisuals() { } GitVisuals.prototype.drawVisuals = function(sys, ctx, canvas) { - this.drawRefs(sys, ctx, canvas); };