2018-06-04 23:20:38 -07:00
|
|
|
" Tests for smartindent
|
2017-03-28 16:30:54 -07:00
|
|
|
|
|
|
|
" Tests for not doing smart indenting when it isn't set.
|
2020-11-29 23:08:27 -07:00
|
|
|
func Test_nosmartindent()
|
2017-03-28 16:30:54 -07:00
|
|
|
new
|
|
|
|
call append(0, [" some test text",
|
2020-11-29 23:08:27 -07:00
|
|
|
\ " test text",
|
|
|
|
\ "test text",
|
|
|
|
\ " test text"])
|
2017-03-28 16:30:54 -07:00
|
|
|
set nocindent nosmartindent autoindent
|
|
|
|
exe "normal! gg/some\<CR>"
|
|
|
|
exe "normal! 2cc#test\<Esc>"
|
|
|
|
call assert_equal(" #test", getline(1))
|
|
|
|
enew! | close
|
2020-11-29 23:08:27 -07:00
|
|
|
endfunc
|
2018-06-04 23:20:38 -07:00
|
|
|
|
2020-11-29 23:08:27 -07:00
|
|
|
func MyIndent()
|
|
|
|
endfunc
|
2018-06-04 23:20:38 -07:00
|
|
|
|
|
|
|
" When 'indentexpr' is set, setting 'si' has no effect.
|
2020-11-29 23:08:27 -07:00
|
|
|
func Test_smartindent_has_no_effect()
|
2018-06-04 23:20:38 -07:00
|
|
|
new
|
|
|
|
exe "normal! i\<Tab>one\<Esc>"
|
|
|
|
set noautoindent
|
|
|
|
set smartindent
|
|
|
|
set indentexpr=
|
|
|
|
exe "normal! Gotwo\<Esc>"
|
|
|
|
call assert_equal("\ttwo", getline("$"))
|
|
|
|
|
|
|
|
set indentexpr=MyIndent
|
|
|
|
exe "normal! Gothree\<Esc>"
|
|
|
|
call assert_equal("three", getline("$"))
|
|
|
|
|
|
|
|
delfunction! MyIndent
|
|
|
|
set autoindent&
|
|
|
|
set smartindent&
|
|
|
|
set indentexpr&
|
|
|
|
bwipe!
|
2020-11-29 23:08:27 -07:00
|
|
|
endfunc
|
2018-06-04 23:20:38 -07:00
|
|
|
|
|
|
|
" vim: shiftwidth=2 sts=2 expandtab
|