diff options
author | Shougo Matsushita <Shougo.Matsu@gmail.com> | 2017-03-04 12:35:40 +0900 |
---|---|---|
committer | Shougo Matsushita <Shougo.Matsu@gmail.com> | 2017-03-05 12:02:42 +0900 |
commit | cf0b344df14aa5de16ab0a7081ef20d44360c45e (patch) | |
tree | 5b926af1ba3b7a6d7448d2aefc571da64fb23d62 | |
parent | 4303399c10b7106ccf350e8a419fe3c15b81c8e0 (diff) | |
download | rneovim-cf0b344df14aa5de16ab0a7081ef20d44360c45e.tar.gz rneovim-cf0b344df14aa5de16ab0a7081ef20d44360c45e.tar.bz2 rneovim-cf0b344df14aa5de16ab0a7081ef20d44360c45e.zip |
vim-patch:8.0.0347
Problem: When using CTRL-X CTRL-U inside a comment, the use of the comment
leader may not work. (Klement)
Solution: Save and restore did_ai. (Christian Brabandt, closes vim/vim#1494)
https://github.com/vim/vim/commit/d099e033703ce0772f152b8df8a763f0b65303ee
-rw-r--r-- | src/nvim/edit.c | 3 | ||||
-rw-r--r-- | src/nvim/testdir/test_popup.vim | 19 |
2 files changed, 22 insertions, 0 deletions
diff --git a/src/nvim/edit.c b/src/nvim/edit.c index ccb4455d03..aa029c38a2 100644 --- a/src/nvim/edit.c +++ b/src/nvim/edit.c @@ -4344,6 +4344,7 @@ static int ins_complete(int c, bool enable_pum) int save_w_wrow; int save_w_leftcol; int insert_match; + int save_did_ai = did_ai; compl_direction = ins_compl_key2dir(c); insert_match = ins_compl_use_match(c); @@ -4559,6 +4560,8 @@ static int ins_complete(int c, bool enable_pum) if (*funcname == NUL) { EMSG2(_(e_notset), ctrl_x_mode == CTRL_X_FUNCTION ? "completefunc" : "omnifunc"); + // restore did_ai, so that adding comment leader works + did_ai = save_did_ai; return FAIL; } diff --git a/src/nvim/testdir/test_popup.vim b/src/nvim/testdir/test_popup.vim index 259e0149af..fd0f3c0d2d 100644 --- a/src/nvim/testdir/test_popup.vim +++ b/src/nvim/testdir/test_popup.vim @@ -522,4 +522,23 @@ func Test_completion_can_undo() iunmap <Right> endfunc +func Test_completion_comment_formatting() + new + setl formatoptions=tcqro + call feedkeys("o/*\<cr>\<cr>/\<esc>", 'tx') + call assert_equal(['', '/*', ' *', ' */'], getline(1,4)) + %d + call feedkeys("o/*\<cr>foobar\<cr>/\<esc>", 'tx') + call assert_equal(['', '/*', ' * foobar', ' */'], getline(1,4)) + %d + try + call feedkeys("o/*\<cr>\<cr>\<c-x>\<c-u>/\<esc>", 'tx') + call assert_false(1, 'completefunc not set, should have failed') + catch + call assert_exception('E764:') + endtry + call assert_equal(['', '/*', ' *', ' */'], getline(1,4)) + bwipe! +endfunc + " vim: shiftwidth=2 sts=2 expandtab |