summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2023-01-01 18:04:33 +0000
committerBram Moolenaar <Bram@vim.org>2023-01-01 18:04:33 +0000
commitfc966c19f85afc6b856a06c00a93c4fe96280d31 (patch)
treed572275a08c5e978e69f1dcd401dd9a23c9b969b
parentec8b74f7ab37ac83045c9eba723daf3ff8d62fc2 (diff)
patch 9.0.1126: bracketed paste can be enabled when it is not recognizedv9.0.1126
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.
-rw-r--r--runtime/doc/term.txt6
-rw-r--r--src/edit.c2
-rw-r--r--src/normal.c2
-rw-r--r--src/proto/term.pro1
-rw-r--r--src/term.c19
-rw-r--r--src/version.c2
6 files changed, 27 insertions, 5 deletions
diff --git a/runtime/doc/term.txt b/runtime/doc/term.txt
index f519bed762..8b8214c300 100644
--- a/runtime/doc/term.txt
+++ b/runtime/doc/term.txt
@@ -1,4 +1,4 @@
-*term.txt* For Vim version 9.0. Last change: 2022 Dec 31
+*term.txt* For Vim version 9.0. Last change: 2023 Jan 01
VIM REFERENCE MANUAL by Bram Moolenaar
@@ -118,6 +118,10 @@ have a problem with this, disable bracketed paste by putting this in your
If this is done while Vim is running the 't_BD' will be sent to the terminal
to disable bracketed paste.
+If |t_PS| or |t_PE| is not set, then |t_BE| will not be used. This is to make
+sure that bracketed paste is not enabled when the escape codes surrounding
+pasted text cannot be recognized.
+
If your terminal supports bracketed paste, but the options are not set
automatically, you can try using something like this: >
diff --git a/src/edit.c b/src/edit.c
index 85d59d1fb1..4a89fe13fb 100644
--- a/src/edit.c
+++ b/src/edit.c
@@ -3714,7 +3714,7 @@ ins_esc(
MAY_WANT_TO_LOG_THIS;
// Re-enable bracketed paste mode.
- out_str(T_BE);
+ out_str_t_BE();
// Re-enable modifyOtherKeys.
out_str_t_TI();
diff --git a/src/normal.c b/src/normal.c
index 4df6b6a506..cc4e2467fc 100644
--- a/src/normal.c
+++ b/src/normal.c
@@ -454,7 +454,7 @@ normal_cmd_get_more_chars(
MAY_WANT_TO_LOG_THIS;
// Re-enable bracketed paste mode and modifyOtherKeys
- out_str(T_BE);
+ out_str_t_BE();
out_str_t_TI();
}
diff --git a/src/proto/term.pro b/src/proto/term.pro
index 93edba1c0e..8c8b813521 100644
--- a/src/proto/term.pro
+++ b/src/proto/term.pro
@@ -49,6 +49,7 @@ void shell_resized_check(void);
void set_shellsize(int width, int height, int mustset);
void out_str_t_TE(void);
void out_str_t_TI(void);
+void out_str_t_BE(void);
void may_send_t_RK(void);
void settmode(tmode_T tmode);
void starttermcap(void);
diff --git a/src/term.c b/src/term.c
index e7466e684f..0bb6d71904 100644
--- a/src/term.c
+++ b/src/term.c
@@ -3757,6 +3757,21 @@ out_str_t_TI(void)
}
/*
+ * Output T_BE, but only when t_PS and t_PE are set.
+ */
+ void
+out_str_t_BE(void)
+{
+ char_u *p;
+
+ if (T_BE == NULL || *T_BE == NUL
+ || (p = find_termcode((char_u *)"PS")) == NULL || *p == NUL
+ || (p = find_termcode((char_u *)"PE")) == NULL || *p == NUL)
+ return;
+ out_str(T_BE);
+}
+
+/*
* If t_TI was recently sent and there is no typeahead or work to do, now send
* t_RK. This is postponed to avoid the response arriving in a shell command
* or after Vim exits.
@@ -3834,7 +3849,7 @@ settmode(tmode_T tmode)
}
else
{
- out_str(T_BE); // enable bracketed paste mode (should
+ out_str_t_BE(); // enable bracketed paste mode (should
// be before mch_settmode().
out_str_t_TI(); // possibly enables modifyOtherKeys
}
@@ -3862,7 +3877,7 @@ starttermcap(void)
out_str(T_TI); // start termcap mode
out_str_t_TI(); // start "raw" mode
out_str(T_KS); // start "keypad transmit" mode
- out_str(T_BE); // enable bracketed paste mode
+ out_str_t_BE(); // enable bracketed paste mode
#if defined(UNIX) || defined(VMS)
// Enable xterm's focus reporting mode when 'esckeys' is set.
diff --git a/src/version.c b/src/version.c
index 5688d0d7bc..389209aae3 100644
--- a/src/version.c
+++ b/src/version.c
@@ -696,6 +696,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 1126,
+/**/
1125,
/**/
1124,