Skip to content

Commit 9e817c8

Browse files
committed
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)
1 parent ba47b51 commit 9e817c8

3 files changed

Lines changed: 20 additions & 0 deletions

File tree

src/edit.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9463,12 +9463,17 @@ bracketed_paste(paste_mode_T mode, int drop, garray_T *gap)
94639463
char_u *end = find_termcode((char_u *)"PE");
94649464
int ret_char = -1;
94659465
int save_allow_keys = allow_keys;
9466+
int save_paste = p_paste;
9467+
int save_ai = curbuf->b_p_ai;
94669468

94679469
/* If the end code is too long we can't detect it, read everything. */
94689470
if (STRLEN(end) >= NUMBUFLEN)
94699471
end = NULL;
94709472
++no_mapping;
94719473
allow_keys = 0;
9474+
p_paste = TRUE;
9475+
curbuf->b_p_ai = FALSE;
9476+
94729477
for (;;)
94739478
{
94749479
/* When the end is not defined read everything. */
@@ -9534,8 +9539,11 @@ bracketed_paste(paste_mode_T mode, int drop, garray_T *gap)
95349539
}
95359540
idx = 0;
95369541
}
9542+
95379543
--no_mapping;
95389544
allow_keys = save_allow_keys;
9545+
p_paste = save_paste;
9546+
curbuf->b_p_ai = save_ai;
95399547

95409548
return ret_char;
95419549
}

src/testdir/test_paste.vim

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,16 @@ func Test_paste_insert_mode()
3535
call assert_equal('bar donfoo', getline(3))
3636
call assert_equal('bar doneeb', getline(4))
3737
call assert_equal('c', getline(5))
38+
39+
set ai et tw=10
40+
call setline(1, ['a', ' b', 'c'])
41+
2
42+
call feedkeys("A\<Esc>[200~foo\<CR> bar bar bar\<Esc>[201~\<Esc>", 'xt')
43+
call assert_equal(' bfoo', getline(2))
44+
call assert_equal(' bar bar bar', getline(3))
45+
call assert_equal('c', getline(4))
46+
47+
set ai& et& tw=0
3848
bwipe!
3949
endfunc
4050

src/version.c

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

765765
static int included_patches[] =
766766
{ /* Add new patch number below this line */
767+
/**/
768+
238,
767769
/**/
768770
237,
769771
/**/

0 commit comments

Comments
 (0)