mirror of
https://github.com/tmux/tmux.git
synced 2026-05-30 22:26:18 +00:00
Increase escape delay if the buffer contains a partial paste end, fixes
issues with at least Windows Terminal. From jing dot empty at gmail.com GitHub issue 5088.
This commit is contained in:
1
tmux.h
1
tmux.h
@@ -1661,6 +1661,7 @@ struct tty {
|
|||||||
#define TTY_WINSIZEQUERY 0x1000
|
#define TTY_WINSIZEQUERY 0x1000
|
||||||
#define TTY_WAITFG 0x2000
|
#define TTY_WAITFG 0x2000
|
||||||
#define TTY_WAITBG 0x4000
|
#define TTY_WAITBG 0x4000
|
||||||
|
#define TTY_BRACKETPASTE 0x8000
|
||||||
#define TTY_ALL_REQUEST_FLAGS \
|
#define TTY_ALL_REQUEST_FLAGS \
|
||||||
(TTY_HAVEDA|TTY_HAVEDA2|TTY_HAVEXDA)
|
(TTY_HAVEDA|TTY_HAVEDA2|TTY_HAVEXDA)
|
||||||
int flags;
|
int flags;
|
||||||
|
|||||||
23
tty-keys.c
23
tty-keys.c
@@ -605,6 +605,17 @@ tty_keys_find1(struct tty_key *tk, const char *buf, size_t len, size_t *size)
|
|||||||
return (tty_keys_find1(tk, buf, len, size));
|
return (tty_keys_find1(tk, buf, len, size));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
tty_keys_partial_paste_end(const char *buf, size_t len)
|
||||||
|
{
|
||||||
|
static const char paste_end[] = "\033[201~";
|
||||||
|
size_t paste_end_len = (sizeof paste_end) - 1;
|
||||||
|
|
||||||
|
if (len == 0 || len >= paste_end_len)
|
||||||
|
return (0);
|
||||||
|
return (memcmp(buf, paste_end, len) == 0);
|
||||||
|
}
|
||||||
|
|
||||||
/* Look up part of the next key. */
|
/* Look up part of the next key. */
|
||||||
static int
|
static int
|
||||||
tty_keys_next1(struct tty *tty, const char *buf, size_t len, key_code *key,
|
tty_keys_next1(struct tty *tty, const char *buf, size_t len, key_code *key,
|
||||||
@@ -630,6 +641,10 @@ tty_keys_next1(struct tty *tty, const char *buf, size_t len, key_code *key,
|
|||||||
if (tk->next != NULL && !expired)
|
if (tk->next != NULL && !expired)
|
||||||
return (1);
|
return (1);
|
||||||
*key = tk->key;
|
*key = tk->key;
|
||||||
|
if ((*key & KEYC_MASK_KEY) == KEYC_PASTE_START)
|
||||||
|
tty->flags |= TTY_BRACKETPASTE;
|
||||||
|
else if ((*key & KEYC_MASK_KEY) == KEYC_PASTE_END)
|
||||||
|
tty->flags &= ~TTY_BRACKETPASTE;
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -955,10 +970,16 @@ partial_key:
|
|||||||
delay = options_get_number(global_options, "escape-time");
|
delay = options_get_number(global_options, "escape-time");
|
||||||
if (delay == 0)
|
if (delay == 0)
|
||||||
delay = 1;
|
delay = 1;
|
||||||
|
if ((tty->flags & TTY_BRACKETPASTE) &&
|
||||||
|
tty_keys_partial_paste_end(buf, len)) {
|
||||||
|
log_debug("%s: increasing delay (partial paste end)", c->name);
|
||||||
|
if (delay < 500)
|
||||||
|
delay = 500;
|
||||||
|
}
|
||||||
if ((tty->flags & (TTY_WAITFG|TTY_WAITBG) ||
|
if ((tty->flags & (TTY_WAITFG|TTY_WAITBG) ||
|
||||||
(tty->flags & TTY_ALL_REQUEST_FLAGS) != TTY_ALL_REQUEST_FLAGS) ||
|
(tty->flags & TTY_ALL_REQUEST_FLAGS) != TTY_ALL_REQUEST_FLAGS) ||
|
||||||
!TAILQ_EMPTY(&c->input_requests)) {
|
!TAILQ_EMPTY(&c->input_requests)) {
|
||||||
log_debug("%s: increasing delay for active query", c->name);
|
log_debug("%s: increasing delay (active query)", c->name);
|
||||||
if (delay < 500)
|
if (delay < 500)
|
||||||
delay = 500;
|
delay = 500;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user