neovim

Neovim text editor
git clone https://git.dasho.dev/neovim.git
Log | Files | Refs | README

commit dca0412d378131ca6c8a64f7adb8937493c43883
parent 24eb1af4754b3061d0968112342ca5389b68d4f6
Author: zeertzjq <zeertzjq@outlook.com>
Date:   Sat, 14 May 2022 19:57:00 +0800

vim-patch:8.2.4953: with 'si' inserting '}' after completion goes wrong

Problem:    With 'smartindent' inserting '}' after completion goes wrong.
Solution:   Check the cursor is in indent.  (closes vim/vim#10420)
https://github.com/vim/vim/commit/2e444bbef0f36535bf941f007f2961f3f66bbe87

Diffstat:
Msrc/nvim/edit.c | 6++----
Msrc/nvim/testdir/test_smartindent.vim | 5+++++
2 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/src/nvim/edit.c b/src/nvim/edit.c @@ -9344,10 +9344,8 @@ static void ins_try_si(int c) /* * do some very smart indenting when entering '{' or '}' */ - if (((did_si || can_si_back) && c == '{') || (can_si && c == '}')) { - /* - * for '}' set indent equal to indent of line containing matching '{' - */ + if (((did_si || can_si_back) && c == '{') || (can_si && c == '}' && inindent(0))) { + // for '}' set indent equal to indent of line containing matching '{' if (c == '}' && (pos = findmatch(NULL, '{')) != NULL) { old_pos = curwin->w_cursor; /* diff --git a/src/nvim/testdir/test_smartindent.vim b/src/nvim/testdir/test_smartindent.vim @@ -67,6 +67,11 @@ func Test_si_after_completion() call setline(1, 'foo foot') call feedkeys("o f\<C-X>\<C-N>#", 'tx') call assert_equal(' foo#', getline(2)) + + call setline(2, '') + call feedkeys("1Go f\<C-X>\<C-N>}", 'tx') + call assert_equal(' foo}', getline(2)) + bwipe! endfunc