Mercurial > vim
changeset 12551:a69d3595d773 v8.0.1154
patch 8.0.1154: 'indentkeys' does not work properly
commit https://github.com/vim/vim/commit/1b38344e00af65df12946fffda7f3201621c35ef
Author: Bram Moolenaar <Bram@vim.org>
Date: Tue Sep 26 20:04:54 2017 +0200
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 https://github.com/vim/vim/issues/2151)
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Tue, 26 Sep 2017 20:15:05 +0200 |
parents | 60eb2d98df06 |
children | 572c4fe58bcf |
files | src/edit.c src/testdir/test_edit.vim src/version.c |
diffstat | 3 files changed, 30 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/src/edit.c +++ b/src/edit.c @@ -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; }
--- a/src/testdir/test_edit.vim +++ b/src/testdir/test_edit.vim @@ -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