Skip to content

Commit 1b38344

Browse files
committed
patch 8.0.1154: 'indentkeys' does not work properly
Problem: 'indentkeys' does not work properly. (Gary Johnson) Solution: Get the cursor line again. (Christian Brabandt, closes #2151)
1 parent 97fbc40 commit 1b38344

File tree

3 files changed

+30
-1
lines changed

3 files changed

+30
-1
lines changed

src/edit.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8202,7 +8202,7 @@ in_cinkeys(
82028202
{
82038203
/* "0=word": Check if there are only blanks before the
82048204
* word. */
8205-
if (getwhitecols(line) !=
8205+
if (getwhitecols_curline() !=
82068206
(int)(curwin->w_cursor.col - (p - look)))
82078207
match = FALSE;
82088208
}

src/testdir/test_edit.vim

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -314,6 +314,33 @@ func! Test_edit_11()
314314
bw!
315315
endfunc
316316

317+
func! Test_edit_11_indentexpr()
318+
" Test that indenting kicks in
319+
new
320+
" Use indentexpr instead of cindenting
321+
func! Do_Indent()
322+
let pline=prevnonblank(v:lnum)
323+
if empty(getline(v:lnum))
324+
if getline(pline) =~ 'if\|then'
325+
return shiftwidth()
326+
else
327+
return 0
328+
endif
329+
else
330+
return 0
331+
endif
332+
endfunc
333+
setl indentexpr=Do_Indent() indentkeys+=0=then,0=fi
334+
call setline(1, ['if [ $this ]'])
335+
call cursor(1, 1)
336+
call feedkeys("othen\<cr>that\<cr>fi", 'tnix')
337+
call assert_equal(['if [ $this ]', "then", "\<tab>that", "fi"], getline(1, '$'))
338+
set cinkeys&vim indentkeys&vim
339+
set nocindent indentexpr=
340+
delfu Do_Indent
341+
bw!
342+
endfunc
343+
317344
func! Test_edit_12()
318345
" Test changing indent in replace mode
319346
new

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -761,6 +761,8 @@ static char *(features[]) =
761761

762762
static int included_patches[] =
763763
{ /* Add new patch number below this line */
764+
/**/
765+
1154,
764766
/**/
765767
1153,
766768
/**/

0 commit comments

Comments
 (0)