]> granicus.if.org Git - vim/commitdiff
patch 8.0.0238: bracketed paste does not disable autoindent v8.0.0238
authorBram Moolenaar <Bram@vim.org>
Wed, 25 Jan 2017 20:36:17 +0000 (21:36 +0100)
committerBram Moolenaar <Bram@vim.org>
Wed, 25 Jan 2017 20:36:17 +0000 (21:36 +0100)
Problem:    When using bracketed paste autoindent causes indent to be
            increased.
Solution:   Disable 'ai' and set 'paste' temporarily. (Ken Takata)

src/edit.c
src/testdir/test_paste.vim
src/version.c

index 2e1aa2beace19a51816891c60498d45d2c9ee8b5..af1d00b85d866d9f509d557bb382066179727049 100644 (file)
@@ -9463,12 +9463,17 @@ bracketed_paste(paste_mode_T mode, int drop, garray_T *gap)
     char_u     *end = find_termcode((char_u *)"PE");
     int                ret_char = -1;
     int                save_allow_keys = allow_keys;
+    int                save_paste = p_paste;
+    int                save_ai = curbuf->b_p_ai;
 
     /* If the end code is too long we can't detect it, read everything. */
     if (STRLEN(end) >= NUMBUFLEN)
        end = NULL;
     ++no_mapping;
     allow_keys = 0;
+    p_paste = TRUE;
+    curbuf->b_p_ai = FALSE;
+
     for (;;)
     {
        /* When the end is not defined read everything. */
@@ -9534,8 +9539,11 @@ bracketed_paste(paste_mode_T mode, int drop, garray_T *gap)
        }
        idx = 0;
     }
+
     --no_mapping;
     allow_keys = save_allow_keys;
+    p_paste = save_paste;
+    curbuf->b_p_ai = save_ai;
 
     return ret_char;
 }
index dfe6bdc875ae884c09bc730cd21ac911a5378747..996177142129727fd823485c89895850beeaeb1e 100644 (file)
@@ -35,6 +35,16 @@ func Test_paste_insert_mode()
   call assert_equal('bar donfoo', getline(3))
   call assert_equal('bar doneeb', getline(4))
   call assert_equal('c', getline(5))
+
+  set ai et tw=10
+  call setline(1, ['a', '    b', 'c'])
+  2
+  call feedkeys("A\<Esc>[200~foo\<CR> bar bar bar\<Esc>[201~\<Esc>", 'xt')
+  call assert_equal('    bfoo', getline(2))
+  call assert_equal(' bar bar bar', getline(3))
+  call assert_equal('c', getline(4))
+
+  set ai& et& tw=0
   bwipe!
 endfunc
 
index 68ea529097a8266e586fc95f56f79dfe5de80be3..d8952160029ccfe9f89186e93d851664525e9324 100644 (file)
@@ -764,6 +764,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    238,
 /**/
     237,
 /**/