diff --git a/input-keys.c b/input-keys.c index 5c6e05c7..b47eea6e 100644 --- a/input-keys.c +++ b/input-keys.c @@ -587,9 +587,10 @@ input_key(struct screen *s, struct bufferevent *bev, key_code key) newkey = options_get_number(global_options, "backspace"); if (newkey == KEYC_BSPACE) newkey = '\b'; - log_debug("%s: key 0x%llx is backspace -> 0x%llx", __func__, - key, newkey|(key & KEYC_MASK_FLAGS)); - key = newkey|(key & KEYC_MASK_FLAGS); + newkey |= (key & (KEYC_MASK_FLAGS|KEYC_MASK_MODIFIERS)); + log_debug("%s: key 0x%llx is backspace -> 0x%llx", __func__, key, + newkey); + key = newkey; } /* Is this backtab? */ @@ -644,8 +645,7 @@ input_key(struct screen *s, struct bufferevent *bev, key_code key) if (ike != NULL) { log_debug("%s: found key 0x%llx: \"%s\"", __func__, key, ike->data); - if ((key == KEYC_PASTE_START || key == KEYC_PASTE_END) && - (~s->mode & MODE_BRACKETPASTE)) + if (KEYC_IS_PASTE(key) && (~s->mode & MODE_BRACKETPASTE)) return (0); if ((key & KEYC_META) && (~key & KEYC_IMPLIED_META)) input_key_write(__func__, bev, "\033", 1); diff --git a/server-client.c b/server-client.c index 7ba34097..9ced4482 100644 --- a/server-client.c +++ b/server-client.c @@ -2577,7 +2577,7 @@ paste_key: if (c->flags & CLIENT_READONLY) goto out; if (event->buf != NULL) - window_pane_paste(wp, event->buf, event->len); + window_pane_paste(wp, key, event->buf, event->len); key = KEYC_NONE; goto out; diff --git a/tmux.h b/tmux.h index 8cffe09c..1a71b328 100644 --- a/tmux.h +++ b/tmux.h @@ -174,6 +174,10 @@ struct winlink; (((key) & KEYC_MASK_KEY) < KEYC_USER || \ ((key) & KEYC_MASK_KEY) >= KEYC_USER_END)) +/* Is this a paste key? */ +#define KEYC_IS_PASTE(key) \ + ((key) == KEYC_PASTE_START || (key) == KEYC_PASTE_END) + /* Multiple click timeout. */ #define KEYC_CLICK_TIMEOUT 300 @@ -3208,7 +3212,8 @@ void window_pane_reset_mode_all(struct window_pane *); int window_pane_key(struct window_pane *, struct client *, struct session *, struct winlink *, key_code, struct mouse_event *); -void window_pane_paste(struct window_pane *, char *, size_t); +void window_pane_paste(struct window_pane *, key_code, char *, + size_t); int window_pane_visible(struct window_pane *); int window_pane_exited(struct window_pane *); u_int window_pane_search(struct window_pane *, const char *, int, diff --git a/window.c b/window.c index 1f5cdc75..11a00172 100644 --- a/window.c +++ b/window.c @@ -1229,7 +1229,7 @@ window_pane_copy_key(struct window_pane *wp, key_code key) } void -window_pane_paste(struct window_pane *wp, char *buf, size_t len) +window_pane_paste(struct window_pane *wp, key_code key, char *buf, size_t len) { if (!TAILQ_EMPTY(&wp->modes)) return; @@ -1237,6 +1237,9 @@ window_pane_paste(struct window_pane *wp, char *buf, size_t len) if (wp->fd == -1 || wp->flags & PANE_INPUTOFF) return; + if (KEYC_IS_PASTE(key) && (~wp->screen->mode & MODE_BRACKETPASTE)) + return; + log_debug("%s: %.*s", __func__, (int)len, buf); bufferevent_write(wp->event, buf, len);