=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/tmux/Attic/xterm-keys.c,v retrieving revision 1.21 retrieving revision 1.22 diff -c -r1.21 -r1.22 *** src/usr.bin/tmux/Attic/xterm-keys.c 2017/01/25 14:36:08 1.21 --- src/usr.bin/tmux/Attic/xterm-keys.c 2017/05/07 21:25:59 1.22 *************** *** 1,4 **** ! /* $OpenBSD: xterm-keys.c,v 1.21 2017/01/25 14:36:08 nicm Exp $ */ /* * Copyright (c) 2009 Nicholas Marriott --- 1,4 ---- ! /* $OpenBSD: xterm-keys.c,v 1.22 2017/05/07 21:25:59 nicm Exp $ */ /* * Copyright (c) 2009 Nicholas Marriott *************** *** 197,203 **** if (matched == -1) continue; if (matched == 0) ! *key = entry->key | modifiers; return (matched); } return (-1); --- 197,203 ---- if (matched == -1) continue; if (matched == 0) ! *key = (entry->key|modifiers|KEYC_XTERM); return (matched); } return (-1); *************** *** 227,234 **** if (modifiers == 1) return (NULL); /* Otherwise, find the key in the table. */ ! key &= ~(KEYC_SHIFT|KEYC_ESCAPE|KEYC_CTRL); for (i = 0; i < nitems(xterm_keys_table); i++) { entry = &xterm_keys_table[i]; if (key == entry->key) --- 227,242 ---- if (modifiers == 1) return (NULL); + /* + * If this has the escape modifier, but was not originally an xterm + * key, it may be a genuine escape + key. So don't pass it through as + * an xterm key or programs like vi may be confused. + */ + if ((key & (KEYC_ESCAPE|KEYC_XTERM)) == KEYC_ESCAPE) + return (NULL); + /* Otherwise, find the key in the table. */ ! key &= KEYC_MASK_KEY; for (i = 0; i < nitems(xterm_keys_table); i++) { entry = &xterm_keys_table[i]; if (key == entry->key)