From 44c019871c37f20d270f1d397188259e0b9f1577 Mon Sep 17 00:00:00 2001 From: Fabian Jakobs Date: Thu, 10 Nov 2011 17:14:17 +0100 Subject: [PATCH] add removeCommand function --- lib/ace/commands/command_manager.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/lib/ace/commands/command_manager.js b/lib/ace/commands/command_manager.js index a9e3bd9f..c667ab3e 100644 --- a/lib/ace/commands/command_manager.js +++ b/lib/ace/commands/command_manager.js @@ -20,6 +20,22 @@ var CommandManager = function(commands) { this._buildKeyHash(command); } }; + + function removeCommand(command) { + var name = (typeof command === 'string' ? command : command.name); + command = this.commands[name]; + delete commands[name]; + + // exaustive search is a little bit brute force but since removeCommand is + // not a performance critical operation this should be OK + var ckb = this.commmandKeyBinding; + for (var hashId in ckb) { + for (var key in ckb[hashId]) { + if (ckb[hashId][key] == command) + delete ckb[hashId][key]; + } + } + }; var platform = useragent.isMac ? "mac" : "win";