Skip to content

Commit

Permalink
fix #2957. fix unit tests by re-enabling multiple bindings.
Browse files Browse the repository at this point in the history
  • Loading branch information
jasonsanjose committed Jun 25, 2013
1 parent 64f706f commit 17d917a
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 15 deletions.
5 changes: 2 additions & 3 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -157,9 +157,8 @@ module.exports = function (grunt) {
grunt.registerTask('install', ['write-config']);

// task: test
//grunt.registerTask('test', ['jshint', 'jasmine']);
// grunt.registerTask('test', ['jshint', 'jasmine-node']);
grunt.registerTask('test', ['jshint']);
grunt.registerTask('test', ['jshint:all', 'jasmine']);
//grunt.registerTask('test', ['jshint:all', 'jasmine', jasmine-node']);

// task: set-sprint
// Update sprint number in package.json and rewrite src/config.json
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"grunt-cli": "0.1.6",
"phantomjs": "1.9.0-1",
"grunt-lib-phantomjs": "0.3.0",
"grunt-contrib-jshint": "0.2.0",
"grunt-contrib-jshint": "0.6.0",
"grunt-contrib-watch": "0.3.1",
"grunt-contrib-jasmine": "0.4.2",
"grunt-template-jasmine-requirejs": "0.1.0",
Expand All @@ -35,4 +35,4 @@
"url": "https://github.com/adobe/brackets/blob/master/LICENSE"
}
]
}
}
33 changes: 24 additions & 9 deletions src/command/KeyBindingManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
*/


/*jslint vars: true, plusplus: true, devel: true, nomen: true, indent: 4, maxerr: 50, regexp: true, boss: true */
/*jslint vars: true, plusplus: true, devel: true, nomen: true, indent: 4, maxerr: 50, regexp: true*/
/*global define, $, brackets, window */
/*unittests: KeyBindingManager */

Expand All @@ -40,6 +40,10 @@ define(function (require, exports, module) {
Strings = require("strings");

var KeyboardPrefs = JSON.parse(require("text!base-config/keyboard.json"));

var ADD_BINDING_ERROR = {
EXPLICIT_BINDING_EXISTS: 1
};

/**
* @private
Expand Down Expand Up @@ -415,8 +419,7 @@ define(function (require, exports, module) {
removeBinding(normalized);
} else {
// do not re-assign a key binding
console.error("Cannot assign " + normalized + " to " + commandID + ". It is already assigned to " + _keyMap[normalized].commandID);
return null;
return { errorType: ADD_BINDING_ERROR.EXPLICIT_BINDING_EXISTS, keyBinding: normalized };
}
}

Expand Down Expand Up @@ -551,7 +554,7 @@ define(function (require, exports, module) {
}

if (Array.isArray(keyBindings)) {
var keyBinding;
var keyBinding, errors = [];
results = [];

keyBindings.sort(function (a, b) {
Expand All @@ -572,17 +575,29 @@ define(function (require, exports, module) {
}
});

keyBindings.some(function addSingleBinding(keyBindingRequest) {
keyBindings.forEach(function addSingleBinding(keyBindingRequest) {
// attempt to add keybinding
keyBinding = _addBinding(commandID, keyBindingRequest, keyBindingRequest.platform);

if (keyBinding) {
results.push(keyBinding);
return true;
if (keyBinding.errorType) {
errors.push(keyBinding);
} else {
results.push(keyBinding);
}
}

return false;
});

if (errors.length) {
// only use console.error if no bindings were assigned
var logType = (results.length === 0) ? "error" : "log";

errors.forEach(function (error) {
if (error.errorType === ADD_BINDING_ERROR.EXPLICIT_BINDING_EXISTS) {
console[logType]("Cannot assign " + error.keyBinding + " to " + commandID + ". It is already assigned to " + _keyMap[error.keyBinding].commandID);
}
});
}
} else {
results = _addBinding(commandID, keyBindings, platform);
}
Expand Down
2 changes: 1 addition & 1 deletion src/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
"grunt-cli": "0.1.6",
"phantomjs": "1.9.0-1",
"grunt-lib-phantomjs": "0.3.0",
"grunt-contrib-jshint": "0.2.0",
"grunt-contrib-jshint": "0.6.0",
"grunt-contrib-watch": "0.3.1",
"grunt-contrib-jasmine": "0.4.2",
"grunt-template-jasmine-requirejs": "0.1.0",
Expand Down

0 comments on commit 17d917a

Please sign in to comment.