]> granicus.if.org Git - vim/commitdiff
patch 8.0.1154: 'indentkeys' does not work properly v8.0.1154
authorBram Moolenaar <Bram@vim.org>
Tue, 26 Sep 2017 18:04:54 +0000 (20:04 +0200)
committerBram Moolenaar <Bram@vim.org>
Tue, 26 Sep 2017 18:04:54 +0000 (20:04 +0200)
Problem:    'indentkeys' does not work properly. (Gary Johnson)
Solution:   Get the cursor line again. (Christian Brabandt, closes #2151)

src/edit.c
src/testdir/test_edit.vim
src/version.c

index 14201a2ec3e36db56dff7ac0788007beb642ed67..5f513068ae3c21b6d9a1a058464d96f62c98f944 100644 (file)
@@ -8202,7 +8202,7 @@ in_cinkeys(
                {
                    /* "0=word": Check if there are only blanks before the
                     * word. */
-                   if (getwhitecols(line) !=
+                   if (getwhitecols_curline() !=
                                     (int)(curwin->w_cursor.col - (p - look)))
                        match = FALSE;
                }
index 0986bf9b1cfb46871e02cbdb6b51b33ffd1dc55a..cc9540c77ada0a6ecd47c898d973aff15f23faaf 100644 (file)
@@ -314,6 +314,33 @@ func! Test_edit_11()
   bw!
 endfunc
 
+func! Test_edit_11_indentexpr()
+  " Test that indenting kicks in
+  new
+  " Use indentexpr instead of cindenting
+  func! Do_Indent()
+    let pline=prevnonblank(v:lnum)
+    if empty(getline(v:lnum))
+      if getline(pline) =~ 'if\|then'
+        return shiftwidth()
+      else
+        return 0
+      endif
+    else
+        return 0
+    endif
+  endfunc
+  setl indentexpr=Do_Indent() indentkeys+=0=then,0=fi
+  call setline(1, ['if [ $this ]'])
+  call cursor(1, 1)
+  call feedkeys("othen\<cr>that\<cr>fi", 'tnix')
+  call assert_equal(['if [ $this ]', "then", "\<tab>that", "fi"], getline(1, '$'))
+  set cinkeys&vim indentkeys&vim
+  set nocindent indentexpr=
+  delfu Do_Indent
+  bw!
+endfunc
+
 func! Test_edit_12()
   " Test changing indent in replace mode
   new
index b63246e745df98295b7447b0dc6d86a792887f4b..d38664cd947700d7153047988b3f8d476c3ec8e2 100644 (file)
@@ -761,6 +761,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1154,
 /**/
     1153,
 /**/