]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 8.2.4953: with 'si' inserting '}' after completion goes wrong v8.2.4953
authorBram Moolenaar <Bram@vim.org>
Sat, 14 May 2022 11:54:23 +0000 (12:54 +0100)
committerBram Moolenaar <Bram@vim.org>
Sat, 14 May 2022 11:54:23 +0000 (12:54 +0100)
Problem:    With 'smartindent' inserting '}' after completion goes wrong.
Solution:   Check the cursor is in indent.  (closes #10420)

src/indent.c
src/testdir/test_smartindent.vim
src/version.c

index dfc481a7851c5175de65b9a22ed7d56240582ca6..486259ef2ae165f045e6db7934812ce806852556 100644 (file)
@@ -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)
index edfec9a809a10a569599cc0b851c0b8d72b6b514..9bb7b9c22753ae6151ad3d6e63628b1b416d052f 100644 (file)
@@ -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
 
index 9017eeb1f50faab68a472d63fa0e2f5d9e7714f1..81bbdf9583c1fc8df2648da38f646ebdac8c317a 100644 (file)
@@ -746,6 +746,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    4953,
 /**/
     4952,
 /**/