Skip to content

Commit fc966c1

Browse files
committed
patch 9.0.1126: bracketed paste can be enabled when it is not recognized
Problem: Bracketed paste can be enabled when pasted text is not recognized. Solution: Output t_BE only when t_PS and t_PE are set.
1 parent ec8b74f commit fc966c1

6 files changed

Lines changed: 27 additions & 5 deletions

File tree

runtime/doc/term.txt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
*term.txt* For Vim version 9.0. Last change: 2022 Dec 31
1+
*term.txt* For Vim version 9.0. Last change: 2023 Jan 01
22

33

44
VIM REFERENCE MANUAL by Bram Moolenaar
@@ -118,6 +118,10 @@ have a problem with this, disable bracketed paste by putting this in your
118118
If this is done while Vim is running the 't_BD' will be sent to the terminal
119119
to disable bracketed paste.
120120

121+
If |t_PS| or |t_PE| is not set, then |t_BE| will not be used. This is to make
122+
sure that bracketed paste is not enabled when the escape codes surrounding
123+
pasted text cannot be recognized.
124+
121125
If your terminal supports bracketed paste, but the options are not set
122126
automatically, you can try using something like this: >
123127

src/edit.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3714,7 +3714,7 @@ ins_esc(
37143714
MAY_WANT_TO_LOG_THIS;
37153715

37163716
// Re-enable bracketed paste mode.
3717-
out_str(T_BE);
3717+
out_str_t_BE();
37183718

37193719
// Re-enable modifyOtherKeys.
37203720
out_str_t_TI();

src/normal.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -454,7 +454,7 @@ normal_cmd_get_more_chars(
454454
MAY_WANT_TO_LOG_THIS;
455455

456456
// Re-enable bracketed paste mode and modifyOtherKeys
457-
out_str(T_BE);
457+
out_str_t_BE();
458458
out_str_t_TI();
459459
}
460460

src/proto/term.pro

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ void shell_resized_check(void);
4949
void set_shellsize(int width, int height, int mustset);
5050
void out_str_t_TE(void);
5151
void out_str_t_TI(void);
52+
void out_str_t_BE(void);
5253
void may_send_t_RK(void);
5354
void settmode(tmode_T tmode);
5455
void starttermcap(void);

src/term.c

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3756,6 +3756,21 @@ out_str_t_TI(void)
37563756
send_t_RK = TRUE;
37573757
}
37583758

3759+
/*
3760+
* Output T_BE, but only when t_PS and t_PE are set.
3761+
*/
3762+
void
3763+
out_str_t_BE(void)
3764+
{
3765+
char_u *p;
3766+
3767+
if (T_BE == NULL || *T_BE == NUL
3768+
|| (p = find_termcode((char_u *)"PS")) == NULL || *p == NUL
3769+
|| (p = find_termcode((char_u *)"PE")) == NULL || *p == NUL)
3770+
return;
3771+
out_str(T_BE);
3772+
}
3773+
37593774
/*
37603775
* If t_TI was recently sent and there is no typeahead or work to do, now send
37613776
* t_RK. This is postponed to avoid the response arriving in a shell command
@@ -3834,7 +3849,7 @@ settmode(tmode_T tmode)
38343849
}
38353850
else
38363851
{
3837-
out_str(T_BE); // enable bracketed paste mode (should
3852+
out_str_t_BE(); // enable bracketed paste mode (should
38383853
// be before mch_settmode().
38393854
out_str_t_TI(); // possibly enables modifyOtherKeys
38403855
}
@@ -3862,7 +3877,7 @@ starttermcap(void)
38623877
out_str(T_TI); // start termcap mode
38633878
out_str_t_TI(); // start "raw" mode
38643879
out_str(T_KS); // start "keypad transmit" mode
3865-
out_str(T_BE); // enable bracketed paste mode
3880+
out_str_t_BE(); // enable bracketed paste mode
38663881

38673882
#if defined(UNIX) || defined(VMS)
38683883
// Enable xterm's focus reporting mode when 'esckeys' is set.

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -695,6 +695,8 @@ static char *(features[]) =
695695

696696
static int included_patches[] =
697697
{ /* Add new patch number below this line */
698+
/**/
699+
1126,
698700
/**/
699701
1125,
700702
/**/

0 commit comments

Comments
 (0)