Skip to content

Commit 69a76fe

Browse files
committed
patch 8.0.0851: 'smartindent' is used even when 'indentexpr' is set
Problem: 'smartindent' is used even when 'indentexpr' is set. Solution: Ignore 'smartindent' when 'indentexpr' is set. (Hirohito Higashi)
1 parent 01efafa commit 69a76fe

3 files changed

Lines changed: 32 additions & 0 deletions

File tree

src/misc1.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -626,6 +626,9 @@ open_line(
626626
int do_si = (!p_paste && curbuf->b_p_si
627627
# ifdef FEAT_CINDENT
628628
&& !curbuf->b_p_cin
629+
# endif
630+
# ifdef FEAT_EVAL
631+
&& *curbuf->b_p_inde == NUL
629632
# endif
630633
);
631634
int no_si = FALSE; /* reset did_si afterwards */

src/testdir/test_smartindent.vim

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
" Tests for smartindent
12

23
" Tests for not doing smart indenting when it isn't set.
34
function! Test_nosmartindent()
@@ -12,3 +13,29 @@ function! Test_nosmartindent()
1213
call assert_equal(" #test", getline(1))
1314
enew! | close
1415
endfunction
16+
17+
function MyIndent()
18+
endfunction
19+
20+
" When 'indentexpr' is set, setting 'si' has no effect.
21+
function Test_smartindent_has_no_effect()
22+
new
23+
exe "normal! i\<Tab>one\<Esc>"
24+
set noautoindent
25+
set smartindent
26+
set indentexpr=
27+
exe "normal! Gotwo\<Esc>"
28+
call assert_equal("\ttwo", getline("$"))
29+
30+
set indentexpr=MyIndent
31+
exe "normal! Gothree\<Esc>"
32+
call assert_equal("three", getline("$"))
33+
34+
delfunction! MyIndent
35+
set autoindent&
36+
set smartindent&
37+
set indentexpr&
38+
bwipe!
39+
endfunction
40+
41+
" vim: shiftwidth=2 sts=2 expandtab

src/version.c

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

770770
static int included_patches[] =
771771
{ /* Add new patch number below this line */
772+
/**/
773+
851,
772774
/**/
773775
850,
774776
/**/

0 commit comments

Comments
 (0)