summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2017-01-25 21:36:17 +0100
committerBram Moolenaar <Bram@vim.org>2017-01-25 21:36:17 +0100
commit9e817c8a31232eda57963215eb16ee5b1ceefa7b (patch)
tree23b2e9fe6c9cee01f1d920c852187d5ddefe92c1
parentba47b51ff88d91c9bb5aa522183e23a656865697 (diff)
downloadvim-9e817c8a31232eda57963215eb16ee5b1ceefa7b.zip
patch 8.0.0238: bracketed paste does not disable autoindent
Problem: When using bracketed paste autoindent causes indent to be increased. Solution: Disable 'ai' and set 'paste' temporarily. (Ken Takata)
-rw-r--r--src/edit.c8
-rw-r--r--src/testdir/test_paste.vim10
-rw-r--r--src/version.c2
3 files changed, 20 insertions, 0 deletions
diff --git a/src/edit.c b/src/edit.c
index 2e1aa2bea..af1d00b85 100644
--- a/src/edit.c
+++ b/src/edit.c
@@ -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;
}
diff --git a/src/testdir/test_paste.vim b/src/testdir/test_paste.vim
index dfe6bdc87..996177142 100644
--- a/src/testdir/test_paste.vim
+++ b/src/testdir/test_paste.vim
@@ -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
diff --git a/src/version.c b/src/version.c
index 68ea52909..d89521600 100644
--- a/src/version.c
+++ b/src/version.c
@@ -765,6 +765,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 238,
+/**/
237,
/**/
236,