From b2633bba732a4ddd8f847b2bd445e53f93fa5d60 Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Tue, 5 Jun 2018 02:20:38 -0400 Subject: vim-patch:8.0.0851: 'smartindent' is used even when 'indentexpr' is set (#8481) Problem: 'smartindent' is used even when 'indentexpr' is set. Solution: Ignore 'smartindent' when 'indentexpr' is set. (Hirohito Higashi) https://github.com/vim/vim/commit/69a76feda9e9d308be6b5fc2185286a061dfecd6 --- This also fixes "delfunction!" which was not merged fully in a185ab70fd2eb8d55 (vim-patch:8.0.0655) --- src/nvim/ex_cmds.lua | 2 +- src/nvim/misc1.c | 3 ++- src/nvim/testdir/test_smartindent.vim | 27 +++++++++++++++++++++++++++ 3 files changed, 30 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/nvim/ex_cmds.lua b/src/nvim/ex_cmds.lua index ce02808ad3..4e46c5ce45 100644 --- a/src/nvim/ex_cmds.lua +++ b/src/nvim/ex_cmds.lua @@ -698,7 +698,7 @@ return { }, { command='delfunction', - flags=bit.bor(NEEDARG, WORD1, CMDWIN), + flags=bit.bor(BANG, NEEDARG, WORD1, CMDWIN), addr_type=ADDR_LINES, func='ex_delfunction', }, diff --git a/src/nvim/misc1.c b/src/nvim/misc1.c index 28455f0ba9..dc59aa1281 100644 --- a/src/nvim/misc1.c +++ b/src/nvim/misc1.c @@ -106,7 +106,8 @@ open_line ( char_u *p; char_u saved_char = NUL; // init for GCC pos_T *pos; - bool do_si = (!p_paste && curbuf->b_p_si && !curbuf->b_p_cin); + bool do_si = (!p_paste && curbuf->b_p_si && !curbuf->b_p_cin + && *curbuf->b_p_inde == NUL); bool no_si = false; // reset did_si afterwards int first_char = NUL; // init for GCC int vreplace_mode; diff --git a/src/nvim/testdir/test_smartindent.vim b/src/nvim/testdir/test_smartindent.vim index d00eac9798..9e93a55eb0 100644 --- a/src/nvim/testdir/test_smartindent.vim +++ b/src/nvim/testdir/test_smartindent.vim @@ -1,3 +1,4 @@ +" Tests for smartindent " Tests for not doing smart indenting when it isn't set. function! Test_nosmartindent() @@ -12,3 +13,29 @@ function! Test_nosmartindent() call assert_equal(" #test", getline(1)) enew! | close endfunction + +function MyIndent() +endfunction + +" When 'indentexpr' is set, setting 'si' has no effect. +function Test_smartindent_has_no_effect() + new + exe "normal! i\one\" + set noautoindent + set smartindent + set indentexpr= + exe "normal! Gotwo\" + call assert_equal("\ttwo", getline("$")) + + set indentexpr=MyIndent + exe "normal! Gothree\" + call assert_equal("three", getline("$")) + + delfunction! MyIndent + set autoindent& + set smartindent& + set indentexpr& + bwipe! +endfunction + +" vim: shiftwidth=2 sts=2 expandtab -- cgit