=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/tmux/server-client.c,v retrieving revision 1.252 retrieving revision 1.253 diff -c -r1.252 -r1.253 *** src/usr.bin/tmux/server-client.c 2018/07/16 08:48:22 1.252 --- src/usr.bin/tmux/server-client.c 2018/07/17 18:02:40 1.253 *************** *** 1,4 **** ! /* $OpenBSD: server-client.c,v 1.252 2018/07/16 08:48:22 nicm Exp $ */ /* * Copyright (c) 2009 Nicholas Marriott --- 1,4 ---- ! /* $OpenBSD: server-client.c,v 1.253 2018/07/17 18:02:40 nicm Exp $ */ /* * Copyright (c) 2009 Nicholas Marriott *************** *** 884,894 **** /* Forward mouse keys if disabled. */ if (KEYC_IS_MOUSE(key) && !options_get_number(s->options, "mouse")) ! goto forward; /* Treat everything as a regular key when pasting is detected. */ if (!KEYC_IS_MOUSE(key) && server_client_assume_paste(s)) ! goto forward; /* * Work out the current key table. If the pane is in a mode, use --- 884,894 ---- /* Forward mouse keys if disabled. */ if (KEYC_IS_MOUSE(key) && !options_get_number(s->options, "mouse")) ! goto forward_key; /* Treat everything as a regular key when pasting is detected. */ if (!KEYC_IS_MOUSE(key) && server_client_assume_paste(s)) ! goto forward_key; /* * Work out the current key table. If the pane is in a mode, use *************** *** 903,914 **** table = c->keytable; first = table; /* * The prefix always takes precedence and forces a switch to the prefix * table, unless we are already there. */ key0 = (key & ~KEYC_XTERM); - retry: if ((key0 == (key_code)options_get_number(s->options, "prefix") || key0 == (key_code)options_get_number(s->options, "prefix2")) && strcmp(table->name, "prefix") != 0) { --- 903,914 ---- table = c->keytable; first = table; + table_changed: /* * The prefix always takes precedence and forces a switch to the prefix * table, unless we are already there. */ key0 = (key & ~KEYC_XTERM); if ((key0 == (key_code)options_get_number(s->options, "prefix") || key0 == (key_code)options_get_number(s->options, "prefix2")) && strcmp(table->name, "prefix") != 0) { *************** *** 926,931 **** --- 926,932 ---- if (c->flags & CLIENT_REPEAT) log_debug("currently repeating"); + try_again: /* Try to see if there is a key binding in the current table. */ bd_find.key = key0; bd = RB_FIND(key_bindings, &table->key_bindings, &bd_find); *************** *** 941,947 **** c->flags &= ~CLIENT_REPEAT; server_status_client(c); table = c->keytable; ! goto retry; } log_debug("found in key table %s", table->name); --- 942,948 ---- c->flags &= ~CLIENT_REPEAT; server_status_client(c); table = c->keytable; ! goto table_changed; } log_debug("found in key table %s", table->name); *************** *** 976,996 **** } /* ! * No match in this table. If not in the root table or if repeating, ! * switch the client back to the root table and try again. */ - log_debug("not found in key table %s", table->name); if (key0 != KEYC_ANY) { key0 = KEYC_ANY; ! goto retry; } if (!server_client_is_default_key_table(c, table) || (c->flags & CLIENT_REPEAT)) { server_client_set_key_table(c, NULL); c->flags &= ~CLIENT_REPEAT; server_status_client(c); table = c->keytable; ! goto retry; } /* --- 977,1001 ---- } /* ! * No match, try the ANY key. */ if (key0 != KEYC_ANY) { key0 = KEYC_ANY; ! goto try_again; } + + /* + * No match in this table. If not in the root table or if repeating, + * switch the client back to the root table and try again. + */ + log_debug("not found in key table %s", table->name); if (!server_client_is_default_key_table(c, table) || (c->flags & CLIENT_REPEAT)) { server_client_set_key_table(c, NULL); c->flags &= ~CLIENT_REPEAT; server_status_client(c); table = c->keytable; ! goto table_changed; } /* *************** *** 1003,1009 **** return; } ! forward: if (c->flags & CLIENT_READONLY) return; if (wp != NULL) --- 1008,1014 ---- return; } ! forward_key: if (c->flags & CLIENT_READONLY) return; if (wp != NULL)