=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/tmux/input.c,v retrieving revision 1.159 retrieving revision 1.160 diff -u -r1.159 -r1.160 --- src/usr.bin/tmux/input.c 2019/08/05 06:42:02 1.159 +++ src/usr.bin/tmux/input.c 2019/09/24 20:44:58 1.160 @@ -1,4 +1,4 @@ -/* $OpenBSD: input.c,v 1.159 2019/08/05 06:42:02 nicm Exp $ */ +/* $OpenBSD: input.c,v 1.160 2019/09/24 20:44:58 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott @@ -888,7 +888,8 @@ { struct input_ctx *ictx = wp->ictx; struct screen_write_ctx *sctx = &ictx->ctx; - const struct input_transition *itr; + const struct input_state *state = NULL; + const struct input_transition *itr = NULL; size_t off = 0; if (len == 0) @@ -916,16 +917,22 @@ ictx->ch = buf[off++]; /* Find the transition. */ - itr = ictx->state->transitions; - while (itr->first != -1 && itr->last != -1) { - if (ictx->ch >= itr->first && ictx->ch <= itr->last) - break; - itr++; + if (ictx->state != state || + itr == NULL || + ictx->ch < itr->first || + ictx->ch > itr->last) { + itr = ictx->state->transitions; + while (itr->first != -1 && itr->last != -1) { + if (ictx->ch >= itr->first && ictx->ch <= itr->last) + break; + itr++; + } + if (itr->first == -1 || itr->last == -1) { + /* No transition? Eh? */ + fatalx("no transition from state"); + } } - if (itr->first == -1 || itr->last == -1) { - /* No transition? Eh? */ - fatalx("no transition from state"); - } + state = ictx->state; /* * Any state except print stops the current collection. This is