aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2022-04-08 07:12:47 +0800
committerGitHub <noreply@github.com>2022-04-08 07:12:47 +0800
commit65a5cea0d32a006c996cce08b4a25716e0836c57 (patch)
tree38c7a8d87205c294f438ddc34cac97889d5f1a4c
parent8c25dbff468a6360ac8e22ba1e3fec659db16ab8 (diff)
downloadrneovim-65a5cea0d32a006c996cce08b4a25716e0836c57.tar.gz
rneovim-65a5cea0d32a006c996cce08b4a25716e0836c57.tar.bz2
rneovim-65a5cea0d32a006c996cce08b4a25716e0836c57.zip
vim-patch:8.2.4710: smart indenting does not work after completion (#18030)
Problem: Smart indenting does not work after completion. Solution: Set "can_si". (Christian Brabandt, closes vim/vim#10113, closes vim/vim#558) https://github.com/vim/vim/commit/ac72c21da696cf6c31630a9e5ff4c0d3e2049c11
-rw-r--r--src/nvim/edit.c1
-rw-r--r--src/nvim/testdir/test_ins_complete.vim19
2 files changed, 20 insertions, 0 deletions
diff --git a/src/nvim/edit.c b/src/nvim/edit.c
index 3ab176b2a3..3eb4ab9517 100644
--- a/src/nvim/edit.c
+++ b/src/nvim/edit.c
@@ -1393,6 +1393,7 @@ static void insert_do_complete(InsertState *s)
compl_cont_status = 0;
}
compl_busy = false;
+ can_si = true; // allow smartindenting
}
static void insert_do_cindent(InsertState *s)
diff --git a/src/nvim/testdir/test_ins_complete.vim b/src/nvim/testdir/test_ins_complete.vim
index 186fa8871f..24eaf9e8b1 100644
--- a/src/nvim/testdir/test_ins_complete.vim
+++ b/src/nvim/testdir/test_ins_complete.vim
@@ -707,4 +707,23 @@ func Test_z1_complete_no_history()
close!
endfunc
+func FooBarComplete(findstart, base)
+ if a:findstart
+ return col('.') - 1
+ else
+ return ["Foo", "Bar", "}"]
+ endif
+endfunc
+
+func Test_complete_smartindent()
+ new
+ setlocal smartindent completefunc=FooBarComplete
+
+ exe "norm! o{\<cr>\<c-x>\<c-u>\<c-p>}\<cr>\<esc>"
+ let result = getline(1,'$')
+ call assert_equal(['', '{','}',''], result)
+ bw!
+ delfunction! FooBarComplete
+endfunc
+
" vim: shiftwidth=2 sts=2 expandtab