comparison src/testdir/test_edit.vim @ 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 2dc624388934
children 1fad9675d8fd
comparison
equal deleted inserted replaced
12550:60eb2d98df06 12551:a69d3595d773
306 call cursor(2, 1) 306 call cursor(2, 1)
307 call feedkeys("i\<c-f>int c;\<esc>", 'tnix') 307 call feedkeys("i\<c-f>int c;\<esc>", 'tnix')
308 call cursor(3, 1) 308 call cursor(3, 1)
309 call feedkeys("i/* comment */", 'tnix') 309 call feedkeys("i/* comment */", 'tnix')
310 call assert_equal(['{', "\<tab>\<tab>int c;", "\<tab>\<tab>\<tab>/* comment */"], getline(1, '$')) 310 call assert_equal(['{', "\<tab>\<tab>int c;", "\<tab>\<tab>\<tab>/* comment */"], getline(1, '$'))
311 set cinkeys&vim indentkeys&vim
312 set nocindent indentexpr=
313 delfu Do_Indent
314 bw!
315 endfunc
316
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, '$'))
311 set cinkeys&vim indentkeys&vim 338 set cinkeys&vim indentkeys&vim
312 set nocindent indentexpr= 339 set nocindent indentexpr=
313 delfu Do_Indent 340 delfu Do_Indent
314 bw! 341 bw!
315 endfunc 342 endfunc