blob: e89ad19d3459ee93de44629aff10609cf7d0c41f [file] [log] [blame]
Bram Moolenaar69a76fe2017-08-03 17:54:03 +02001" Tests for smartindent
Bram Moolenaar53f16732016-09-07 20:46:39 +02002
3" Tests for not doing smart indenting when it isn't set.
Bram Moolenaar1e115362019-01-09 23:01:02 +01004func Test_nosmartindent()
Bram Moolenaar53f16732016-09-07 20:46:39 +02005 new
6 call append(0, [" some test text",
Bram Moolenaar1e115362019-01-09 23:01:02 +01007 \ " test text",
8 \ "test text",
9 \ " test text"])
Bram Moolenaar53f16732016-09-07 20:46:39 +020010 set nocindent nosmartindent autoindent
11 exe "normal! gg/some\<CR>"
12 exe "normal! 2cc#test\<Esc>"
13 call assert_equal(" #test", getline(1))
14 enew! | close
Bram Moolenaar1e115362019-01-09 23:01:02 +010015endfunc
Bram Moolenaar69a76fe2017-08-03 17:54:03 +020016
Bram Moolenaar1e115362019-01-09 23:01:02 +010017func MyIndent()
18endfunc
Bram Moolenaar69a76fe2017-08-03 17:54:03 +020019
20" When 'indentexpr' is set, setting 'si' has no effect.
Bram Moolenaar1e115362019-01-09 23:01:02 +010021func Test_smartindent_has_no_effect()
Bram Moolenaar69a76fe2017-08-03 17:54:03 +020022 new
23 exe "normal! i\<Tab>one\<Esc>"
24 set noautoindent
25 set smartindent
26 set indentexpr=
27 exe "normal! Gotwo\<Esc>"
28 call assert_equal("\ttwo", getline("$"))
29
30 set indentexpr=MyIndent
31 exe "normal! Gothree\<Esc>"
32 call assert_equal("three", getline("$"))
33
34 delfunction! MyIndent
35 set autoindent&
36 set smartindent&
37 set indentexpr&
38 bwipe!
Bram Moolenaar1e115362019-01-09 23:01:02 +010039endfunc
Bram Moolenaar69a76fe2017-08-03 17:54:03 +020040
41" vim: shiftwidth=2 sts=2 expandtab