From 374e273df5f66e90e06f60617495446facfbd4f3 Mon Sep 17 00:00:00 2001 From: nicm Date: Thu, 19 Nov 2015 22:46:46 +0000 Subject: [PATCH] Only assume pasting with at least two characters, reduces problems for people who can type ^B c very fast, or who are using tmux inside something else that buffers. --- server-client.c | 12 ++++++++++-- tmux.h | 7 ++++--- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/server-client.c b/server-client.c index 04929dec..64426a70 100644 --- a/server-client.c +++ b/server-client.c @@ -494,8 +494,16 @@ server_client_assume_paste(struct session *s) return (0); timersub(&s->activity_time, &s->last_activity_time, &tv); - if (tv.tv_sec == 0 && tv.tv_usec < t * 1000) - return (1); + if (tv.tv_sec == 0 && tv.tv_usec < t * 1000) { + log_debug("session %s pasting (flag %d)", s->name, + !!(s->flags & SESSION_PASTING)); + if (s->flags & SESSION_PASTING) + return (1); + s->flags |= SESSION_PASTING; + return (0); + } + log_debug("session %s not pasting", s->name); + s->flags &= ~SESSION_PASTING; return (0); } diff --git a/tmux.h b/tmux.h index b6cdcd80..d58ee8c9 100644 --- a/tmux.h +++ b/tmux.h @@ -33,6 +33,8 @@ #include #include +#include "xmalloc.h" + extern char *__progname; extern char **environ; @@ -45,8 +47,6 @@ struct session; struct tmuxpeer; struct tmuxproc; -#include "xmalloc.h" - /* Default global configuration file. */ #define TMUX_CONF "/etc/tmux.conf" @@ -1014,6 +1014,7 @@ struct session { struct options *options; #define SESSION_UNATTACHED 0x1 /* not attached to any clients */ +#define SESSION_PASTING 0x2 int flags; u_int attached; @@ -1147,7 +1148,7 @@ struct tty { struct tty_key *key_tree; }; -/* TTY command context and function pointer. */ +/* TTY command context. */ struct tty_ctx { struct window_pane *wp;