summaryrefslogtreecommitdiff
path: root/usr.bin
diff options
context:
space:
mode:
authorNicholas Marriott <nicm@cvs.openbsd.org>2012-04-22 05:21:41 +0000
committerNicholas Marriott <nicm@cvs.openbsd.org>2012-04-22 05:21:41 +0000
commit505ddb64be21959e3aef2a7746b35191e4d061f2 (patch)
treea5d06e5293020e53d7c8d6af83216aa0cf4739be /usr.bin
parentf2bd5ee5e04d80a88af407de62c61b0bdae16fb2 (diff)
Handle partial keys properly by making sure the timer has actually
expired, fixes problems with mintty reported by Michael Simpson.
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/tmux/tty-keys.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/usr.bin/tmux/tty-keys.c b/usr.bin/tmux/tty-keys.c
index e2ab32dc436..8e96d61c3a0 100644
--- a/usr.bin/tmux/tty-keys.c
+++ b/usr.bin/tmux/tty-keys.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: tty-keys.c,v 1.38 2012/03/21 21:28:03 nicm Exp $ */
+/* $OpenBSD: tty-keys.c,v 1.39 2012/04/22 05:21:40 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -476,7 +476,6 @@ tty_keys_next(struct tty *tty)
goto partial_key;
}
-
/* Is this a mouse key press? */
switch (tty_keys_mouse(tty, buf, len, &size, &mouse)) {
case 0: /* yes */
@@ -532,10 +531,11 @@ tty_keys_next(struct tty *tty)
partial_key:
/*
- * Escape but no key string. If have already seen an escape, then the
- * timer must have expired, so give up waiting and send the escape.
+ * Escape but no key string. If have already seen an escape and the
+ * timer has expired, give up waiting and send the escape.
*/
- if (tty->flags & TTY_ESCAPE) {
+ if ((tty->flags & TTY_ESCAPE) &&
+ !evtimer_pending(&tty->key_timer, NULL)) {
evbuffer_drain(tty->event->input, 1);
key = '\033';
goto handle_key;
@@ -544,6 +544,10 @@ partial_key:
/* Fall through to start the timer. */
start_timer:
+ /* If already waiting for timer, do nothing. */
+ if (evtimer_pending(&tty->key_timer, NULL))
+ return (0);
+
/* Start the timer and wait for expiry or more data. */
delay = options_get_number(&global_options, "escape-time");
tv.tv_sec = delay / 1000;