diff --git a/cmd-send-keys.c b/cmd-send-keys.c index e54574fe..5c6db347 100644 --- a/cmd-send-keys.c +++ b/cmd-send-keys.c @@ -73,7 +73,7 @@ cmd_send_keys_inject(struct client *c, struct cmdq_item *item, key_code key) bd = RB_FIND(key_bindings, &table->key_bindings, &bd_find); if (bd != NULL) { table->references++; - key_bindings_dispatch(bd, c, NULL, &item->target); + key_bindings_dispatch(bd, item, c, NULL, &item->target); key_bindings_unref_table(table); } } diff --git a/key-bindings.c b/key-bindings.c index 9e327655..8f56cbee 100644 --- a/key-bindings.c +++ b/key-bindings.c @@ -400,11 +400,11 @@ key_bindings_read_only(struct cmdq_item *item, __unused void *data) } void -key_bindings_dispatch(struct key_binding *bd, struct client *c, - struct mouse_event *m, struct cmd_find_state *fs) +key_bindings_dispatch(struct key_binding *bd, struct cmdq_item *item, + struct client *c, struct mouse_event *m, struct cmd_find_state *fs) { struct cmd *cmd; - struct cmdq_item *item; + struct cmdq_item *new_item; int readonly; readonly = 1; @@ -413,11 +413,14 @@ key_bindings_dispatch(struct key_binding *bd, struct client *c, readonly = 0; } if (!readonly && (c->flags & CLIENT_READONLY)) - cmdq_append(c, cmdq_get_callback(key_bindings_read_only, NULL)); + new_item = cmdq_get_callback(key_bindings_read_only, NULL); else { - item = cmdq_get_command(bd->cmdlist, fs, m, 0); + new_item = cmdq_get_command(bd->cmdlist, fs, m, 0); if (bd->flags & KEY_BINDING_REPEAT) - item->shared->flags |= CMDQ_SHARED_REPEAT; - cmdq_append(c, item); + new_item->shared->flags |= CMDQ_SHARED_REPEAT; } + if (item != NULL) + cmdq_insert_after(item, new_item); + else + cmdq_append(c, new_item); } diff --git a/server-client.c b/server-client.c index ae8e0d6e..0ac38175 100644 --- a/server-client.c +++ b/server-client.c @@ -947,7 +947,7 @@ retry: server_status_client(c); /* Execute the key binding. */ - key_bindings_dispatch(bd, c, m, &fs); + key_bindings_dispatch(bd, NULL, c, m, &fs); key_bindings_unref_table(table); return; } diff --git a/tmux.h b/tmux.h index ea02cebf..9d0cd960 100644 --- a/tmux.h +++ b/tmux.h @@ -1801,8 +1801,8 @@ void key_bindings_add(const char *, key_code, int, struct cmd_list *); void key_bindings_remove(const char *, key_code); void key_bindings_remove_table(const char *); void key_bindings_init(void); -void key_bindings_dispatch(struct key_binding *, struct client *, - struct mouse_event *, struct cmd_find_state *); +void key_bindings_dispatch(struct key_binding *, struct cmdq_item *, + struct client *, struct mouse_event *, struct cmd_find_state *); /* key-string.c */ key_code key_string_lookup_string(const char *);