Skip to content

Commit

Permalink
patch 8.0.1154: 'indentkeys' does not work properly
Browse files Browse the repository at this point in the history
Problem:    'indentkeys' does not work properly. (Gary Johnson)
Solution:   Get the cursor line again. (Christian Brabandt, closes #2151)
  • Loading branch information
brammool committed Sep 26, 2017
1 parent 97fbc40 commit 1b38344
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/edit.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
27 changes: 27 additions & 0 deletions src/testdir/test_edit.vim
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions src/version.c
Original file line number Diff line number Diff line change
Expand Up @@ -761,6 +761,8 @@ static char *(features[]) =

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

0 comments on commit 1b38344

Please sign in to comment.