Skip to content

Commit

Permalink
patch 8.2.4953: with 'si' inserting '}' after completion goes wrong
Browse files Browse the repository at this point in the history
Problem:    With 'smartindent' inserting '}' after completion goes wrong.
Solution:   Check the cursor is in indent.  (closes #10420)
  • Loading branch information
brammool committed May 14, 2022
1 parent 98feace commit 2e444bb
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/indent.c
Original file line number Diff line number Diff line change
Expand Up @@ -1197,7 +1197,8 @@ ins_try_si(int c)
int temp;

// do some very smart indenting when entering '{' or '}'
if (((did_si || can_si_back) && c == '{') || (can_si && c == '}'))
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)
Expand Down
5 changes: 5 additions & 0 deletions src/testdir/test_smartindent.vim
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,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

Expand Down
2 changes: 2 additions & 0 deletions src/version.c
Original file line number Diff line number Diff line change
Expand Up @@ -746,6 +746,8 @@ static char *(features[]) =

static int included_patches[] =
{ /* Add new patch number below this line */
/**/
4953,
/**/
4952,
/**/
Expand Down

0 comments on commit 2e444bb

Please sign in to comment.