Skip to content

Commit fdd7155

Browse files
committed
patch 8.1.0224: hang in bracketed paste mode when t_PE not encountered
Problem: Hang in bracketed paste mode when t_PE not encountered. Solution: Break out of the loop when got_int is set. (suggested by Christian Brabandt, closes #3146)
1 parent 6ab9e42 commit fdd7155

File tree

2 files changed

+18
-7
lines changed

2 files changed

+18
-7
lines changed

src/edit.c

+16-7
Original file line numberDiff line numberDiff line change
@@ -9685,22 +9685,31 @@ bracketed_paste(paste_mode_T mode, int drop, garray_T *gap)
96859685
int ret_char = -1;
96869686
int save_allow_keys = allow_keys;
96879687
int save_paste = p_paste;
9688-
int save_ai = curbuf->b_p_ai;
96899688

96909689
/* If the end code is too long we can't detect it, read everything. */
96919690
if (STRLEN(end) >= NUMBUFLEN)
96929691
end = NULL;
96939692
++no_mapping;
96949693
allow_keys = 0;
9695-
p_paste = TRUE;
9696-
curbuf->b_p_ai = FALSE;
9694+
if (!p_paste)
9695+
// Also have the side effects of setting 'paste' to make it work much
9696+
// faster.
9697+
set_option_value((char_u *)"paste", TRUE, NULL, 0);
96979698

96989699
for (;;)
96999700
{
9700-
/* When the end is not defined read everything. */
9701+
// When the end is not defined read everything there is.
97019702
if (end == NULL && vpeekc() == NUL)
97029703
break;
9703-
c = plain_vgetc();
9704+
do
9705+
{
9706+
c = vgetc();
9707+
} while (c == K_IGNORE || c == K_VER_SCROLLBAR || c == K_HOR_SCROLLBAR);
9708+
if (c == NUL || got_int)
9709+
// When CTRL-C was encountered the typeahead will be flushed and we
9710+
// won't get the end sequence.
9711+
break;
9712+
97049713
#ifdef FEAT_MBYTE
97059714
if (has_mbyte)
97069715
idx += (*mb_char2bytes)(c, buf + idx);
@@ -9763,8 +9772,8 @@ bracketed_paste(paste_mode_T mode, int drop, garray_T *gap)
97639772

97649773
--no_mapping;
97659774
allow_keys = save_allow_keys;
9766-
p_paste = save_paste;
9767-
curbuf->b_p_ai = save_ai;
9775+
if (!save_paste)
9776+
set_option_value((char_u *)"paste", FALSE, NULL, 0);
97689777

97699778
return ret_char;
97709779
}

src/version.c

+2
Original file line numberDiff line numberDiff line change
@@ -798,6 +798,8 @@ static char *(features[]) =
798798

799799
static int included_patches[] =
800800
{ /* Add new patch number below this line */
801+
/**/
802+
224,
801803
/**/
802804
223,
803805
/**/

0 commit comments

Comments
 (0)