aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2022-10-15 19:42:38 +0800
committerzeertzjq <zeertzjq@outlook.com>2022-10-15 19:44:03 +0800
commit32ced1f08fd551770b4f4a0fd69dfe2d36c417b6 (patch)
treebf58e72746b37c0204aaacc3e666d1ff6f93da95
parenteaac0958256f2fb3b0fa9d20790bc38ed9eb3005 (diff)
downloadrneovim-32ced1f08fd551770b4f4a0fd69dfe2d36c417b6.tar.gz
rneovim-32ced1f08fd551770b4f4a0fd69dfe2d36c417b6.tar.bz2
rneovim-32ced1f08fd551770b4f4a0fd69dfe2d36c417b6.zip
vim-patch:9.0.0754: 'indentexpr' overrules lisp indenting in one situation
Problem: 'indentexpr' overrules lisp indenting in one situation. Solution: Add "else" to keep the lisp indent. (issue vim/vim#11327) https://github.com/vim/vim/commit/a79b35b5781ae770334cec781d17fec3875f8108
-rw-r--r--src/nvim/change.c8
-rw-r--r--src/nvim/testdir/test_lispindent.vim11
2 files changed, 14 insertions, 5 deletions
diff --git a/src/nvim/change.c b/src/nvim/change.c
index c9e57ab88f..c6f9e9f5c2 100644
--- a/src/nvim/change.c
+++ b/src/nvim/change.c
@@ -1814,17 +1814,15 @@ int open_line(int dir, int flags, int second_line_indent, bool *did_do_comment)
vreplace_mode = 0;
}
- // May do lisp indenting.
if (!p_paste
&& leader == NULL
&& curbuf->b_p_lisp
&& curbuf->b_p_ai) {
+ // do lisp indenting
fixthisline(get_lisp_indent);
ai_col = (colnr_T)getwhitecols_curline();
- }
-
- // May do indenting after opening a new line.
- if (do_cindent) {
+ } else if (do_cindent) {
+ // do 'cindent' or 'indentexpr' indenting
do_c_expr_indent();
ai_col = (colnr_T)getwhitecols_curline();
}
diff --git a/src/nvim/testdir/test_lispindent.vim b/src/nvim/testdir/test_lispindent.vim
index d4cab6d17e..8987f67a80 100644
--- a/src/nvim/testdir/test_lispindent.vim
+++ b/src/nvim/testdir/test_lispindent.vim
@@ -91,6 +91,17 @@ func Test_lispindent_negative()
call assert_equal(-1, lispindent(-1))
endfunc
+func Test_lispindent_with_indentexpr()
+ enew
+ setl ai lisp nocin indentexpr=11
+ exe "normal a(x\<CR>1\<CR>2)\<Esc>"
+ let expected = ['(x', ' 1', ' 2)']
+ call assert_equal(expected, getline(1, 3))
+ normal 1G=G
+ call assert_equal(expected, getline(1, 3))
+ bwipe!
+endfunc
+
func Test_lisp_indent_works()
" This was reading beyond the end of the line
new