]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 9.0.1126: bracketed paste can be enabled when it is not recognized v9.0.1126
authorBram Moolenaar <Bram@vim.org>
Sun, 1 Jan 2023 18:04:33 +0000 (18:04 +0000)
committerBram Moolenaar <Bram@vim.org>
Sun, 1 Jan 2023 18:04:33 +0000 (18:04 +0000)
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.

runtime/doc/term.txt
src/edit.c
src/normal.c
src/proto/term.pro
src/term.c
src/version.c

index f519bed762f18df727beef09bbc491d41cb8efd1..8b8214c300bf2829e7076a746ee9d93636ab835c 100644 (file)
@@ -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: >
 
index 85d59d1fb1dc1aa0e9e94449de993b59d848a991..4a89fe13fbf9c8744ddfebbba9d212da9df545e2 100644 (file)
@@ -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();
index 4df6b6a50647671324ebaf71b5783eb5758f6138..cc4e2467fcc5fc0417921859c29b54769f93f37d 100644 (file)
@@ -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();
        }
 
index 93edba1c0ebd38f80023adb41a494df45eb7da38..8c8b813521e8cc7b4ed7df90d339539654fa290f 100644 (file)
@@ -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);
index e7466e684f03aee1381050c6217da7055bd91259..0bb6d71904a32a33cb867d363fd6e91890b09279 100644 (file)
@@ -3756,6 +3756,21 @@ out_str_t_TI(void)
     send_t_RK = TRUE;
 }
 
+/*
+ * 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
@@ -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.
index 5688d0d7bc20987b8fdb7104b0b60ac47c2e4f52..389209aae39335289d5f4548fd64181c0e0952ed 100644 (file)
@@ -695,6 +695,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1126,
 /**/
     1125,
 /**/