Code

When adding a keybinding check if the key is already bound
authorJonas Fonseca <fonseca@diku.dk>
Thu, 22 Apr 2010 02:34:12 +0000 (22:34 -0400)
committerJonas Fonseca <fonseca@diku.dk>
Thu, 22 Apr 2010 02:35:28 +0000 (22:35 -0400)
... and then overwrite it with the new request.

tig.c

diff --git a/tig.c b/tig.c
index 7eb9f71b6827036fea61d811fedd0296d0a7dc28..0c57533fb7c9319315b5cd675083c31ea09c0bfc 100644 (file)
--- a/tig.c
+++ b/tig.c
@@ -1522,6 +1522,14 @@ static void
 add_keybinding(enum keymap keymap, enum request request, int key)
 {
        struct keybinding_table *table = &keybindings[keymap];
+       size_t i;
+
+       for (i = 0; i < keybindings[keymap].size; i++) {
+               if (keybindings[keymap].data[i].alias == key) {
+                       keybindings[keymap].data[i].request = request;
+                       return;
+               }
+       }
 
        table->data = realloc(table->data, (table->size + 1) * sizeof(*table->data));
        if (!table->data)