From a7136933b3e63ec5a7a50cd1dab9547b51f2d6d9 Mon Sep 17 00:00:00 2001 From: Stephen Blott Date: Sun, 28 Feb 2016 08:34:14 +0000 Subject: Key bindings; handle overlapping bindings With: map g something map gg somethingElse The mapping for "g" always takes priority, regardless of the order in which they're encountered in `@keyToCommandRegistry`. --- background_scripts/commands.coffee | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'background_scripts/commands.coffee') diff --git a/background_scripts/commands.coffee b/background_scripts/commands.coffee index 2982b861..10d20753 100644 --- a/background_scripts/commands.coffee +++ b/background_scripts/commands.coffee @@ -106,7 +106,9 @@ Commands = while 0 < keys.length [key, rest] = if 0 == keys.search @namedKeyRegex then [RegExp.$1, RegExp.$2] else [keys[0], keys[1..]] if 0 < rest.length - currentMapping = currentMapping[key] ?= {} + # Do not overwrite existing command bindings, they take priority. + break if (currentMapping[key] ?= {}).command + currentMapping = currentMapping[key] else currentMapping[key] = registryEntry keys = rest -- cgit v1.2.3