annotate src/testdir/test_indent.vim @ 28817:1ad71fcbf546 v8.2.4932

patch 8.2.4932: not easy to filter the output of maplist() Commit: https://github.com/vim/vim/commit/d8f5f766219273a8579947cc80b92580b6988a4b Author: Ernie Rael <errael@raelity.com> Date: Tue May 10 17:50:39 2022 +0100 patch 8.2.4932: not easy to filter the output of maplist() Problem: Not easy to filter the output of maplist(). Solution: Add mode_bits to the dictionary. (Ernie Rael, closes https://github.com/vim/vim/issues/10356)
author Bram Moolenaar <Bram@vim.org>
date Tue, 10 May 2022 19:00:04 +0200
parents b6f2f545f8cc
children a2c89e5446b7
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
19603
6d3c683466f4 patch 8.2.0358: insufficient testing for indent.c
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1 " Test for various indent options
6d3c683466f4 patch 8.2.0358: insufficient testing for indent.c
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2
6d3c683466f4 patch 8.2.0358: insufficient testing for indent.c
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3 func Test_preserveindent()
6d3c683466f4 patch 8.2.0358: insufficient testing for indent.c
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4 new
6d3c683466f4 patch 8.2.0358: insufficient testing for indent.c
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5 " Test for autoindent copying indent from the previous line
6d3c683466f4 patch 8.2.0358: insufficient testing for indent.c
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
6 setlocal autoindent
6d3c683466f4 patch 8.2.0358: insufficient testing for indent.c
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
7 call setline(1, [repeat(' ', 16) .. 'line1'])
6d3c683466f4 patch 8.2.0358: insufficient testing for indent.c
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
8 call feedkeys("A\nline2", 'xt')
6d3c683466f4 patch 8.2.0358: insufficient testing for indent.c
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
9 call assert_equal("\t\tline2", getline(2))
6d3c683466f4 patch 8.2.0358: insufficient testing for indent.c
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
10 setlocal autoindent&
6d3c683466f4 patch 8.2.0358: insufficient testing for indent.c
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
11
6d3c683466f4 patch 8.2.0358: insufficient testing for indent.c
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
12 " Test for using CTRL-T with and without 'preserveindent'
6d3c683466f4 patch 8.2.0358: insufficient testing for indent.c
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
13 set shiftwidth=4
6d3c683466f4 patch 8.2.0358: insufficient testing for indent.c
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
14 call cursor(1, 1)
6d3c683466f4 patch 8.2.0358: insufficient testing for indent.c
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
15 call setline(1, " \t ")
6d3c683466f4 patch 8.2.0358: insufficient testing for indent.c
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
16 call feedkeys("Al\<C-T>", 'xt')
6d3c683466f4 patch 8.2.0358: insufficient testing for indent.c
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
17 call assert_equal("\t\tl", getline(1))
6d3c683466f4 patch 8.2.0358: insufficient testing for indent.c
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
18 set preserveindent
6d3c683466f4 patch 8.2.0358: insufficient testing for indent.c
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
19 call setline(1, " \t ")
6d3c683466f4 patch 8.2.0358: insufficient testing for indent.c
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
20 call feedkeys("Al\<C-T>", 'xt')
6d3c683466f4 patch 8.2.0358: insufficient testing for indent.c
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
21 call assert_equal(" \t \tl", getline(1))
6d3c683466f4 patch 8.2.0358: insufficient testing for indent.c
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
22 set pi& sw&
6d3c683466f4 patch 8.2.0358: insufficient testing for indent.c
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
23
6d3c683466f4 patch 8.2.0358: insufficient testing for indent.c
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
24 " Test for using CTRL-T with 'expandtab' and 'preserveindent'
6d3c683466f4 patch 8.2.0358: insufficient testing for indent.c
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
25 call cursor(1, 1)
6d3c683466f4 patch 8.2.0358: insufficient testing for indent.c
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
26 call setline(1, "\t \t")
6d3c683466f4 patch 8.2.0358: insufficient testing for indent.c
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
27 set shiftwidth=4 expandtab preserveindent
6d3c683466f4 patch 8.2.0358: insufficient testing for indent.c
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
28 call feedkeys("Al\<C-T>", 'xt')
6d3c683466f4 patch 8.2.0358: insufficient testing for indent.c
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
29 call assert_equal("\t \t l", getline(1))
6d3c683466f4 patch 8.2.0358: insufficient testing for indent.c
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
30 set sw& et& pi&
6d3c683466f4 patch 8.2.0358: insufficient testing for indent.c
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
31
6d3c683466f4 patch 8.2.0358: insufficient testing for indent.c
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
32 close!
6d3c683466f4 patch 8.2.0358: insufficient testing for indent.c
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
33 endfunc
6d3c683466f4 patch 8.2.0358: insufficient testing for indent.c
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
34
6d3c683466f4 patch 8.2.0358: insufficient testing for indent.c
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
35 " Test for indent()
6d3c683466f4 patch 8.2.0358: insufficient testing for indent.c
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
36 func Test_indent_func()
6d3c683466f4 patch 8.2.0358: insufficient testing for indent.c
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
37 call assert_equal(-1, indent(-1))
6d3c683466f4 patch 8.2.0358: insufficient testing for indent.c
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
38 new
6d3c683466f4 patch 8.2.0358: insufficient testing for indent.c
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
39 call setline(1, "\tabc")
6d3c683466f4 patch 8.2.0358: insufficient testing for indent.c
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
40 call assert_equal(8, indent(1))
6d3c683466f4 patch 8.2.0358: insufficient testing for indent.c
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
41 call setline(1, " abc")
6d3c683466f4 patch 8.2.0358: insufficient testing for indent.c
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
42 call assert_equal(4, indent(1))
6d3c683466f4 patch 8.2.0358: insufficient testing for indent.c
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
43 call setline(1, " \t abc")
6d3c683466f4 patch 8.2.0358: insufficient testing for indent.c
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
44 call assert_equal(12, indent(1))
6d3c683466f4 patch 8.2.0358: insufficient testing for indent.c
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
45 close!
6d3c683466f4 patch 8.2.0358: insufficient testing for indent.c
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
46 endfunc
6d3c683466f4 patch 8.2.0358: insufficient testing for indent.c
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
47
6d3c683466f4 patch 8.2.0358: insufficient testing for indent.c
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
48 " Test for reindenting a line using the '=' operator
6d3c683466f4 patch 8.2.0358: insufficient testing for indent.c
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
49 func Test_reindent()
6d3c683466f4 patch 8.2.0358: insufficient testing for indent.c
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
50 new
6d3c683466f4 patch 8.2.0358: insufficient testing for indent.c
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
51 call setline(1, 'abc')
6d3c683466f4 patch 8.2.0358: insufficient testing for indent.c
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
52 set nomodifiable
6d3c683466f4 patch 8.2.0358: insufficient testing for indent.c
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
53 call assert_fails('normal ==', 'E21:')
6d3c683466f4 patch 8.2.0358: insufficient testing for indent.c
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
54 set modifiable
6d3c683466f4 patch 8.2.0358: insufficient testing for indent.c
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
55
6d3c683466f4 patch 8.2.0358: insufficient testing for indent.c
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
56 call setline(1, ['foo', 'bar'])
6d3c683466f4 patch 8.2.0358: insufficient testing for indent.c
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
57 call feedkeys('ggVG=', 'xt')
6d3c683466f4 patch 8.2.0358: insufficient testing for indent.c
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
58 call assert_equal(['foo', 'bar'], getline(1, 2))
6d3c683466f4 patch 8.2.0358: insufficient testing for indent.c
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
59 close!
6d3c683466f4 patch 8.2.0358: insufficient testing for indent.c
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
60 endfunc
6d3c683466f4 patch 8.2.0358: insufficient testing for indent.c
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
61
28536
b6f2f545f8cc patch 8.2.4792: indent operator creates an undo entry for every line
Bram Moolenaar <Bram@vim.org>
parents: 26448
diff changeset
62 " Test indent operator creating one undo entry
b6f2f545f8cc patch 8.2.4792: indent operator creates an undo entry for every line
Bram Moolenaar <Bram@vim.org>
parents: 26448
diff changeset
63 func Test_indent_operator_undo()
b6f2f545f8cc patch 8.2.4792: indent operator creates an undo entry for every line
Bram Moolenaar <Bram@vim.org>
parents: 26448
diff changeset
64 enew
b6f2f545f8cc patch 8.2.4792: indent operator creates an undo entry for every line
Bram Moolenaar <Bram@vim.org>
parents: 26448
diff changeset
65 call setline(1, range(12)->map('"\t" .. v:val'))
b6f2f545f8cc patch 8.2.4792: indent operator creates an undo entry for every line
Bram Moolenaar <Bram@vim.org>
parents: 26448
diff changeset
66 func FoldExpr()
b6f2f545f8cc patch 8.2.4792: indent operator creates an undo entry for every line
Bram Moolenaar <Bram@vim.org>
parents: 26448
diff changeset
67 let g:foldcount += 1
b6f2f545f8cc patch 8.2.4792: indent operator creates an undo entry for every line
Bram Moolenaar <Bram@vim.org>
parents: 26448
diff changeset
68 return '='
b6f2f545f8cc patch 8.2.4792: indent operator creates an undo entry for every line
Bram Moolenaar <Bram@vim.org>
parents: 26448
diff changeset
69 endfunc
b6f2f545f8cc patch 8.2.4792: indent operator creates an undo entry for every line
Bram Moolenaar <Bram@vim.org>
parents: 26448
diff changeset
70 set foldmethod=expr foldexpr=FoldExpr()
b6f2f545f8cc patch 8.2.4792: indent operator creates an undo entry for every line
Bram Moolenaar <Bram@vim.org>
parents: 26448
diff changeset
71 let g:foldcount = 0
b6f2f545f8cc patch 8.2.4792: indent operator creates an undo entry for every line
Bram Moolenaar <Bram@vim.org>
parents: 26448
diff changeset
72 redraw
b6f2f545f8cc patch 8.2.4792: indent operator creates an undo entry for every line
Bram Moolenaar <Bram@vim.org>
parents: 26448
diff changeset
73 call assert_equal(12, g:foldcount)
b6f2f545f8cc patch 8.2.4792: indent operator creates an undo entry for every line
Bram Moolenaar <Bram@vim.org>
parents: 26448
diff changeset
74 normal gg=G
b6f2f545f8cc patch 8.2.4792: indent operator creates an undo entry for every line
Bram Moolenaar <Bram@vim.org>
parents: 26448
diff changeset
75 call assert_equal(24, g:foldcount)
b6f2f545f8cc patch 8.2.4792: indent operator creates an undo entry for every line
Bram Moolenaar <Bram@vim.org>
parents: 26448
diff changeset
76 undo
b6f2f545f8cc patch 8.2.4792: indent operator creates an undo entry for every line
Bram Moolenaar <Bram@vim.org>
parents: 26448
diff changeset
77 call assert_equal(38, g:foldcount)
b6f2f545f8cc patch 8.2.4792: indent operator creates an undo entry for every line
Bram Moolenaar <Bram@vim.org>
parents: 26448
diff changeset
78
b6f2f545f8cc patch 8.2.4792: indent operator creates an undo entry for every line
Bram Moolenaar <Bram@vim.org>
parents: 26448
diff changeset
79 bwipe!
b6f2f545f8cc patch 8.2.4792: indent operator creates an undo entry for every line
Bram Moolenaar <Bram@vim.org>
parents: 26448
diff changeset
80 set foldmethod& foldexpr=
b6f2f545f8cc patch 8.2.4792: indent operator creates an undo entry for every line
Bram Moolenaar <Bram@vim.org>
parents: 26448
diff changeset
81 delfunc FoldExpr
b6f2f545f8cc patch 8.2.4792: indent operator creates an undo entry for every line
Bram Moolenaar <Bram@vim.org>
parents: 26448
diff changeset
82 unlet g:foldcount
b6f2f545f8cc patch 8.2.4792: indent operator creates an undo entry for every line
Bram Moolenaar <Bram@vim.org>
parents: 26448
diff changeset
83 endfunc
b6f2f545f8cc patch 8.2.4792: indent operator creates an undo entry for every line
Bram Moolenaar <Bram@vim.org>
parents: 26448
diff changeset
84
19603
6d3c683466f4 patch 8.2.0358: insufficient testing for indent.c
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
85 " Test for shifting a line with a preprocessor directive ('#')
6d3c683466f4 patch 8.2.0358: insufficient testing for indent.c
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
86 func Test_preproc_indent()
6d3c683466f4 patch 8.2.0358: insufficient testing for indent.c
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
87 new
6d3c683466f4 patch 8.2.0358: insufficient testing for indent.c
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
88 set sw=4
6d3c683466f4 patch 8.2.0358: insufficient testing for indent.c
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
89 call setline(1, '#define FOO 1')
6d3c683466f4 patch 8.2.0358: insufficient testing for indent.c
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
90 normal >>
6d3c683466f4 patch 8.2.0358: insufficient testing for indent.c
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
91 call assert_equal(' #define FOO 1', getline(1))
6d3c683466f4 patch 8.2.0358: insufficient testing for indent.c
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
92
6d3c683466f4 patch 8.2.0358: insufficient testing for indent.c
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
93 " with 'smartindent'
6d3c683466f4 patch 8.2.0358: insufficient testing for indent.c
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
94 call setline(1, '#define FOO 1')
6d3c683466f4 patch 8.2.0358: insufficient testing for indent.c
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
95 set smartindent
6d3c683466f4 patch 8.2.0358: insufficient testing for indent.c
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
96 normal >>
6d3c683466f4 patch 8.2.0358: insufficient testing for indent.c
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
97 call assert_equal('#define FOO 1', getline(1))
6d3c683466f4 patch 8.2.0358: insufficient testing for indent.c
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
98 set smartindent&
6d3c683466f4 patch 8.2.0358: insufficient testing for indent.c
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
99
6d3c683466f4 patch 8.2.0358: insufficient testing for indent.c
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
100 " with 'cindent'
6d3c683466f4 patch 8.2.0358: insufficient testing for indent.c
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
101 set cindent
6d3c683466f4 patch 8.2.0358: insufficient testing for indent.c
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
102 normal >>
6d3c683466f4 patch 8.2.0358: insufficient testing for indent.c
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
103 call assert_equal('#define FOO 1', getline(1))
6d3c683466f4 patch 8.2.0358: insufficient testing for indent.c
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
104 set cindent&
6d3c683466f4 patch 8.2.0358: insufficient testing for indent.c
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
105
6d3c683466f4 patch 8.2.0358: insufficient testing for indent.c
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
106 close!
6d3c683466f4 patch 8.2.0358: insufficient testing for indent.c
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
107 endfunc
6d3c683466f4 patch 8.2.0358: insufficient testing for indent.c
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
108
6d3c683466f4 patch 8.2.0358: insufficient testing for indent.c
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
109 " Test for 'copyindent'
6d3c683466f4 patch 8.2.0358: insufficient testing for indent.c
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
110 func Test_copyindent()
6d3c683466f4 patch 8.2.0358: insufficient testing for indent.c
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
111 new
6d3c683466f4 patch 8.2.0358: insufficient testing for indent.c
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
112 set shiftwidth=4 autoindent expandtab copyindent
6d3c683466f4 patch 8.2.0358: insufficient testing for indent.c
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
113 call setline(1, " \t abc")
6d3c683466f4 patch 8.2.0358: insufficient testing for indent.c
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
114 call feedkeys("ol", 'xt')
6d3c683466f4 patch 8.2.0358: insufficient testing for indent.c
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
115 call assert_equal(" \t l", getline(2))
6d3c683466f4 patch 8.2.0358: insufficient testing for indent.c
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
116 set noexpandtab
6d3c683466f4 patch 8.2.0358: insufficient testing for indent.c
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
117 call setline(1, " \t abc")
6d3c683466f4 patch 8.2.0358: insufficient testing for indent.c
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
118 call feedkeys("ol", 'xt')
6d3c683466f4 patch 8.2.0358: insufficient testing for indent.c
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
119 call assert_equal(" \t l", getline(2))
6d3c683466f4 patch 8.2.0358: insufficient testing for indent.c
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
120 set sw& ai& et& ci&
6d3c683466f4 patch 8.2.0358: insufficient testing for indent.c
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
121 close!
6d3c683466f4 patch 8.2.0358: insufficient testing for indent.c
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
122 endfunc
6d3c683466f4 patch 8.2.0358: insufficient testing for indent.c
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
123
19613
9c15be376631 patch 8.2.0363: some Normal mode commands not tested
Bram Moolenaar <Bram@vim.org>
parents: 19603
diff changeset
124 " Test for changing multiple lines with lisp indent
9c15be376631 patch 8.2.0363: some Normal mode commands not tested
Bram Moolenaar <Bram@vim.org>
parents: 19603
diff changeset
125 func Test_lisp_indent_change_multiline()
9c15be376631 patch 8.2.0363: some Normal mode commands not tested
Bram Moolenaar <Bram@vim.org>
parents: 19603
diff changeset
126 new
9c15be376631 patch 8.2.0363: some Normal mode commands not tested
Bram Moolenaar <Bram@vim.org>
parents: 19603
diff changeset
127 setlocal lisp autoindent
9c15be376631 patch 8.2.0363: some Normal mode commands not tested
Bram Moolenaar <Bram@vim.org>
parents: 19603
diff changeset
128 call setline(1, ['(if a', ' (if b', ' (return 5)))'])
9c15be376631 patch 8.2.0363: some Normal mode commands not tested
Bram Moolenaar <Bram@vim.org>
parents: 19603
diff changeset
129 normal! jc2j(return 4))
9c15be376631 patch 8.2.0363: some Normal mode commands not tested
Bram Moolenaar <Bram@vim.org>
parents: 19603
diff changeset
130 call assert_equal(' (return 4))', getline(2))
9c15be376631 patch 8.2.0363: some Normal mode commands not tested
Bram Moolenaar <Bram@vim.org>
parents: 19603
diff changeset
131 close!
9c15be376631 patch 8.2.0363: some Normal mode commands not tested
Bram Moolenaar <Bram@vim.org>
parents: 19603
diff changeset
132 endfunc
9c15be376631 patch 8.2.0363: some Normal mode commands not tested
Bram Moolenaar <Bram@vim.org>
parents: 19603
diff changeset
133
9c15be376631 patch 8.2.0363: some Normal mode commands not tested
Bram Moolenaar <Bram@vim.org>
parents: 19603
diff changeset
134 func Test_lisp_indent()
9c15be376631 patch 8.2.0363: some Normal mode commands not tested
Bram Moolenaar <Bram@vim.org>
parents: 19603
diff changeset
135 new
9c15be376631 patch 8.2.0363: some Normal mode commands not tested
Bram Moolenaar <Bram@vim.org>
parents: 19603
diff changeset
136 setlocal lisp autoindent
9c15be376631 patch 8.2.0363: some Normal mode commands not tested
Bram Moolenaar <Bram@vim.org>
parents: 19603
diff changeset
137 call setline(1, ['(if a', ' ;; comment', ' \ abc', '', ' " str1\', ' " st\b', ' (return 5)'])
9c15be376631 patch 8.2.0363: some Normal mode commands not tested
Bram Moolenaar <Bram@vim.org>
parents: 19603
diff changeset
138 normal! jo;; comment
9c15be376631 patch 8.2.0363: some Normal mode commands not tested
Bram Moolenaar <Bram@vim.org>
parents: 19603
diff changeset
139 normal! jo\ abc
9c15be376631 patch 8.2.0363: some Normal mode commands not tested
Bram Moolenaar <Bram@vim.org>
parents: 19603
diff changeset
140 normal! jo;; ret
9c15be376631 patch 8.2.0363: some Normal mode commands not tested
Bram Moolenaar <Bram@vim.org>
parents: 19603
diff changeset
141 normal! jostr1"
9c15be376631 patch 8.2.0363: some Normal mode commands not tested
Bram Moolenaar <Bram@vim.org>
parents: 19603
diff changeset
142 normal! jostr2"
9c15be376631 patch 8.2.0363: some Normal mode commands not tested
Bram Moolenaar <Bram@vim.org>
parents: 19603
diff changeset
143 call assert_equal([' ;; comment', ' ;; comment', ' \ abc', ' \ abc', '', ' ;; ret', ' " str1\', ' str1"', ' " st\b', ' str2"'], getline(2, 11))
9c15be376631 patch 8.2.0363: some Normal mode commands not tested
Bram Moolenaar <Bram@vim.org>
parents: 19603
diff changeset
144 close!
9c15be376631 patch 8.2.0363: some Normal mode commands not tested
Bram Moolenaar <Bram@vim.org>
parents: 19603
diff changeset
145 endfunc
9c15be376631 patch 8.2.0363: some Normal mode commands not tested
Bram Moolenaar <Bram@vim.org>
parents: 19603
diff changeset
146
9c15be376631 patch 8.2.0363: some Normal mode commands not tested
Bram Moolenaar <Bram@vim.org>
parents: 19603
diff changeset
147 " Test for setting the 'indentexpr' from a modeline
9c15be376631 patch 8.2.0363: some Normal mode commands not tested
Bram Moolenaar <Bram@vim.org>
parents: 19603
diff changeset
148 func Test_modeline_indent_expr()
9c15be376631 patch 8.2.0363: some Normal mode commands not tested
Bram Moolenaar <Bram@vim.org>
parents: 19603
diff changeset
149 let modeline = &modeline
9c15be376631 patch 8.2.0363: some Normal mode commands not tested
Bram Moolenaar <Bram@vim.org>
parents: 19603
diff changeset
150 set modeline
9c15be376631 patch 8.2.0363: some Normal mode commands not tested
Bram Moolenaar <Bram@vim.org>
parents: 19603
diff changeset
151 func GetIndent()
9c15be376631 patch 8.2.0363: some Normal mode commands not tested
Bram Moolenaar <Bram@vim.org>
parents: 19603
diff changeset
152 return line('.') * 2
9c15be376631 patch 8.2.0363: some Normal mode commands not tested
Bram Moolenaar <Bram@vim.org>
parents: 19603
diff changeset
153 endfunc
9c15be376631 patch 8.2.0363: some Normal mode commands not tested
Bram Moolenaar <Bram@vim.org>
parents: 19603
diff changeset
154 call writefile(['# vim: indentexpr=GetIndent()'], 'Xfile.txt')
9c15be376631 patch 8.2.0363: some Normal mode commands not tested
Bram Moolenaar <Bram@vim.org>
parents: 19603
diff changeset
155 set modelineexpr
9c15be376631 patch 8.2.0363: some Normal mode commands not tested
Bram Moolenaar <Bram@vim.org>
parents: 19603
diff changeset
156 new Xfile.txt
9c15be376631 patch 8.2.0363: some Normal mode commands not tested
Bram Moolenaar <Bram@vim.org>
parents: 19603
diff changeset
157 call assert_equal('GetIndent()', &indentexpr)
9c15be376631 patch 8.2.0363: some Normal mode commands not tested
Bram Moolenaar <Bram@vim.org>
parents: 19603
diff changeset
158 exe "normal Oa\nb\n"
9c15be376631 patch 8.2.0363: some Normal mode commands not tested
Bram Moolenaar <Bram@vim.org>
parents: 19603
diff changeset
159 call assert_equal([' a', ' b'], getline(1, 2))
19719
a659d390d3fd patch 8.2.0416: test leaves file behind
Bram Moolenaar <Bram@vim.org>
parents: 19613
diff changeset
160
19613
9c15be376631 patch 8.2.0363: some Normal mode commands not tested
Bram Moolenaar <Bram@vim.org>
parents: 19603
diff changeset
161 set modelineexpr&
9c15be376631 patch 8.2.0363: some Normal mode commands not tested
Bram Moolenaar <Bram@vim.org>
parents: 19603
diff changeset
162 delfunc GetIndent
9c15be376631 patch 8.2.0363: some Normal mode commands not tested
Bram Moolenaar <Bram@vim.org>
parents: 19603
diff changeset
163 let &modeline = modeline
9c15be376631 patch 8.2.0363: some Normal mode commands not tested
Bram Moolenaar <Bram@vim.org>
parents: 19603
diff changeset
164 close!
19719
a659d390d3fd patch 8.2.0416: test leaves file behind
Bram Moolenaar <Bram@vim.org>
parents: 19613
diff changeset
165 call delete('Xfile.txt')
19613
9c15be376631 patch 8.2.0363: some Normal mode commands not tested
Bram Moolenaar <Bram@vim.org>
parents: 19603
diff changeset
166 endfunc
9c15be376631 patch 8.2.0363: some Normal mode commands not tested
Bram Moolenaar <Bram@vim.org>
parents: 19603
diff changeset
167
26167
7108cee19a2c patch 8.2.3615: wrong indent in first line if re-formatting with indent expr
Bram Moolenaar <Bram@vim.org>
parents: 19719
diff changeset
168 func Test_indent_func_with_gq()
7108cee19a2c patch 8.2.3615: wrong indent in first line if re-formatting with indent expr
Bram Moolenaar <Bram@vim.org>
parents: 19719
diff changeset
169
7108cee19a2c patch 8.2.3615: wrong indent in first line if re-formatting with indent expr
Bram Moolenaar <Bram@vim.org>
parents: 19719
diff changeset
170 function GetTeXIndent()
7108cee19a2c patch 8.2.3615: wrong indent in first line if re-formatting with indent expr
Bram Moolenaar <Bram@vim.org>
parents: 19719
diff changeset
171 " Sample indent expression for TeX files
7108cee19a2c patch 8.2.3615: wrong indent in first line if re-formatting with indent expr
Bram Moolenaar <Bram@vim.org>
parents: 19719
diff changeset
172 let lnum = prevnonblank(v:lnum - 1)
7108cee19a2c patch 8.2.3615: wrong indent in first line if re-formatting with indent expr
Bram Moolenaar <Bram@vim.org>
parents: 19719
diff changeset
173 " At the start of the file use zero indent.
7108cee19a2c patch 8.2.3615: wrong indent in first line if re-formatting with indent expr
Bram Moolenaar <Bram@vim.org>
parents: 19719
diff changeset
174 if lnum == 0
7108cee19a2c patch 8.2.3615: wrong indent in first line if re-formatting with indent expr
Bram Moolenaar <Bram@vim.org>
parents: 19719
diff changeset
175 return 0
7108cee19a2c patch 8.2.3615: wrong indent in first line if re-formatting with indent expr
Bram Moolenaar <Bram@vim.org>
parents: 19719
diff changeset
176 endif
7108cee19a2c patch 8.2.3615: wrong indent in first line if re-formatting with indent expr
Bram Moolenaar <Bram@vim.org>
parents: 19719
diff changeset
177 let line = getline(lnum)
7108cee19a2c patch 8.2.3615: wrong indent in first line if re-formatting with indent expr
Bram Moolenaar <Bram@vim.org>
parents: 19719
diff changeset
178 let ind = indent(lnum)
7108cee19a2c patch 8.2.3615: wrong indent in first line if re-formatting with indent expr
Bram Moolenaar <Bram@vim.org>
parents: 19719
diff changeset
179 " Add a 'shiftwidth' after beginning of environments.
7108cee19a2c patch 8.2.3615: wrong indent in first line if re-formatting with indent expr
Bram Moolenaar <Bram@vim.org>
parents: 19719
diff changeset
180 if line =~ '\\begin{center}'
7108cee19a2c patch 8.2.3615: wrong indent in first line if re-formatting with indent expr
Bram Moolenaar <Bram@vim.org>
parents: 19719
diff changeset
181 let ind = ind + shiftwidth()
7108cee19a2c patch 8.2.3615: wrong indent in first line if re-formatting with indent expr
Bram Moolenaar <Bram@vim.org>
parents: 19719
diff changeset
182 endif
7108cee19a2c patch 8.2.3615: wrong indent in first line if re-formatting with indent expr
Bram Moolenaar <Bram@vim.org>
parents: 19719
diff changeset
183 return ind
7108cee19a2c patch 8.2.3615: wrong indent in first line if re-formatting with indent expr
Bram Moolenaar <Bram@vim.org>
parents: 19719
diff changeset
184 endfunction
7108cee19a2c patch 8.2.3615: wrong indent in first line if re-formatting with indent expr
Bram Moolenaar <Bram@vim.org>
parents: 19719
diff changeset
185
7108cee19a2c patch 8.2.3615: wrong indent in first line if re-formatting with indent expr
Bram Moolenaar <Bram@vim.org>
parents: 19719
diff changeset
186 new
7108cee19a2c patch 8.2.3615: wrong indent in first line if re-formatting with indent expr
Bram Moolenaar <Bram@vim.org>
parents: 19719
diff changeset
187 setl et sw=2 sts=2 ts=2 tw=50 indentexpr=GetTeXIndent()
7108cee19a2c patch 8.2.3615: wrong indent in first line if re-formatting with indent expr
Bram Moolenaar <Bram@vim.org>
parents: 19719
diff changeset
188 put =[ '\documentclass{article}', '', '\begin{document}', '',
7108cee19a2c patch 8.2.3615: wrong indent in first line if re-formatting with indent expr
Bram Moolenaar <Bram@vim.org>
parents: 19719
diff changeset
189 \ 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Fusce ut enim non',
7108cee19a2c patch 8.2.3615: wrong indent in first line if re-formatting with indent expr
Bram Moolenaar <Bram@vim.org>
parents: 19719
diff changeset
190 \ 'libero efficitur aliquet. Maecenas metus justo, facilisis convallis blandit',
7108cee19a2c patch 8.2.3615: wrong indent in first line if re-formatting with indent expr
Bram Moolenaar <Bram@vim.org>
parents: 19719
diff changeset
191 \ 'non, semper eu urna. Suspendisse diam diam, iaculis faucibus lorem eu,',
7108cee19a2c patch 8.2.3615: wrong indent in first line if re-formatting with indent expr
Bram Moolenaar <Bram@vim.org>
parents: 19719
diff changeset
192 \ 'fringilla condimentum lectus. Quisque euismod diam at convallis vulputate.',
7108cee19a2c patch 8.2.3615: wrong indent in first line if re-formatting with indent expr
Bram Moolenaar <Bram@vim.org>
parents: 19719
diff changeset
193 \ 'Pellentesque laoreet tortor sit amet mauris euismod ornare. Sed varius',
7108cee19a2c patch 8.2.3615: wrong indent in first line if re-formatting with indent expr
Bram Moolenaar <Bram@vim.org>
parents: 19719
diff changeset
194 \ 'bibendum orci vel vehicula. Pellentesque tempor, ipsum et auctor accumsan,',
7108cee19a2c patch 8.2.3615: wrong indent in first line if re-formatting with indent expr
Bram Moolenaar <Bram@vim.org>
parents: 19719
diff changeset
195 \ 'metus lectus ultrices odio, sed elementum mi ante at arcu.', '', '\begin{center}', '',
7108cee19a2c patch 8.2.3615: wrong indent in first line if re-formatting with indent expr
Bram Moolenaar <Bram@vim.org>
parents: 19719
diff changeset
196 \ 'Proin nec risus consequat nunc dapibus consectetur. Mauris lacinia est a augue',
7108cee19a2c patch 8.2.3615: wrong indent in first line if re-formatting with indent expr
Bram Moolenaar <Bram@vim.org>
parents: 19719
diff changeset
197 \ 'tristique accumsan. Morbi pretium, felis molestie eleifend condimentum, arcu',
26448
748793fcb4e2 patch 8.2.3754: undesired changing of the indent of the first formatted line
Bram Moolenaar <Bram@vim.org>
parents: 26167
diff changeset
198 \ 'ipsum congue nisl, quis euismod purus libero in ante.', '',
748793fcb4e2 patch 8.2.3754: undesired changing of the indent of the first formatted line
Bram Moolenaar <Bram@vim.org>
parents: 26167
diff changeset
199 \ 'Donec id semper purus.',
26167
7108cee19a2c patch 8.2.3615: wrong indent in first line if re-formatting with indent expr
Bram Moolenaar <Bram@vim.org>
parents: 19719
diff changeset
200 \ 'Suspendisse eget aliquam nunc. Maecenas fringilla mauris vitae maximus',
7108cee19a2c patch 8.2.3615: wrong indent in first line if re-formatting with indent expr
Bram Moolenaar <Bram@vim.org>
parents: 19719
diff changeset
201 \ 'condimentum. Cras a quam in mi dictum eleifend at a lorem. Sed convallis',
7108cee19a2c patch 8.2.3615: wrong indent in first line if re-formatting with indent expr
Bram Moolenaar <Bram@vim.org>
parents: 19719
diff changeset
202 \ 'ante a commodo facilisis. Nam suscipit vulputate odio, vel dapibus nisl',
7108cee19a2c patch 8.2.3615: wrong indent in first line if re-formatting with indent expr
Bram Moolenaar <Bram@vim.org>
parents: 19719
diff changeset
203 \ 'dignissim facilisis. Vestibulum ante ipsum primis in faucibus orci luctus et',
7108cee19a2c patch 8.2.3615: wrong indent in first line if re-formatting with indent expr
Bram Moolenaar <Bram@vim.org>
parents: 19719
diff changeset
204 \ 'ultrices posuere cubilia curae;', '', '']
7108cee19a2c patch 8.2.3615: wrong indent in first line if re-formatting with indent expr
Bram Moolenaar <Bram@vim.org>
parents: 19719
diff changeset
205 1d_
7108cee19a2c patch 8.2.3615: wrong indent in first line if re-formatting with indent expr
Bram Moolenaar <Bram@vim.org>
parents: 19719
diff changeset
206 call cursor(5, 1)
7108cee19a2c patch 8.2.3615: wrong indent in first line if re-formatting with indent expr
Bram Moolenaar <Bram@vim.org>
parents: 19719
diff changeset
207 ka
26448
748793fcb4e2 patch 8.2.3754: undesired changing of the indent of the first formatted line
Bram Moolenaar <Bram@vim.org>
parents: 26167
diff changeset
208 call cursor(14, 1)
26167
7108cee19a2c patch 8.2.3615: wrong indent in first line if re-formatting with indent expr
Bram Moolenaar <Bram@vim.org>
parents: 19719
diff changeset
209 kb
7108cee19a2c patch 8.2.3615: wrong indent in first line if re-formatting with indent expr
Bram Moolenaar <Bram@vim.org>
parents: 19719
diff changeset
210 norm! 'agqap
26448
748793fcb4e2 patch 8.2.3754: undesired changing of the indent of the first formatted line
Bram Moolenaar <Bram@vim.org>
parents: 26167
diff changeset
211 norm! 'bgqG
26167
7108cee19a2c patch 8.2.3615: wrong indent in first line if re-formatting with indent expr
Bram Moolenaar <Bram@vim.org>
parents: 19719
diff changeset
212 let expected = [ '\documentclass{article}', '', '\begin{document}', '',
7108cee19a2c patch 8.2.3615: wrong indent in first line if re-formatting with indent expr
Bram Moolenaar <Bram@vim.org>
parents: 19719
diff changeset
213 \ 'Lorem ipsum dolor sit amet, consectetur adipiscing',
7108cee19a2c patch 8.2.3615: wrong indent in first line if re-formatting with indent expr
Bram Moolenaar <Bram@vim.org>
parents: 19719
diff changeset
214 \ 'elit. Fusce ut enim non libero efficitur aliquet.',
7108cee19a2c patch 8.2.3615: wrong indent in first line if re-formatting with indent expr
Bram Moolenaar <Bram@vim.org>
parents: 19719
diff changeset
215 \ 'Maecenas metus justo, facilisis convallis blandit',
7108cee19a2c patch 8.2.3615: wrong indent in first line if re-formatting with indent expr
Bram Moolenaar <Bram@vim.org>
parents: 19719
diff changeset
216 \ 'non, semper eu urna. Suspendisse diam diam,',
7108cee19a2c patch 8.2.3615: wrong indent in first line if re-formatting with indent expr
Bram Moolenaar <Bram@vim.org>
parents: 19719
diff changeset
217 \ 'iaculis faucibus lorem eu, fringilla condimentum',
7108cee19a2c patch 8.2.3615: wrong indent in first line if re-formatting with indent expr
Bram Moolenaar <Bram@vim.org>
parents: 19719
diff changeset
218 \ 'lectus. Quisque euismod diam at convallis',
7108cee19a2c patch 8.2.3615: wrong indent in first line if re-formatting with indent expr
Bram Moolenaar <Bram@vim.org>
parents: 19719
diff changeset
219 \ 'vulputate. Pellentesque laoreet tortor sit amet',
7108cee19a2c patch 8.2.3615: wrong indent in first line if re-formatting with indent expr
Bram Moolenaar <Bram@vim.org>
parents: 19719
diff changeset
220 \ 'mauris euismod ornare. Sed varius bibendum orci',
7108cee19a2c patch 8.2.3615: wrong indent in first line if re-formatting with indent expr
Bram Moolenaar <Bram@vim.org>
parents: 19719
diff changeset
221 \ 'vel vehicula. Pellentesque tempor, ipsum et auctor',
7108cee19a2c patch 8.2.3615: wrong indent in first line if re-formatting with indent expr
Bram Moolenaar <Bram@vim.org>
parents: 19719
diff changeset
222 \ 'accumsan, metus lectus ultrices odio, sed',
7108cee19a2c patch 8.2.3615: wrong indent in first line if re-formatting with indent expr
Bram Moolenaar <Bram@vim.org>
parents: 19719
diff changeset
223 \ 'elementum mi ante at arcu.', '', '\begin{center}', '',
7108cee19a2c patch 8.2.3615: wrong indent in first line if re-formatting with indent expr
Bram Moolenaar <Bram@vim.org>
parents: 19719
diff changeset
224 \ ' Proin nec risus consequat nunc dapibus',
7108cee19a2c patch 8.2.3615: wrong indent in first line if re-formatting with indent expr
Bram Moolenaar <Bram@vim.org>
parents: 19719
diff changeset
225 \ ' consectetur. Mauris lacinia est a augue',
7108cee19a2c patch 8.2.3615: wrong indent in first line if re-formatting with indent expr
Bram Moolenaar <Bram@vim.org>
parents: 19719
diff changeset
226 \ ' tristique accumsan. Morbi pretium, felis',
7108cee19a2c patch 8.2.3615: wrong indent in first line if re-formatting with indent expr
Bram Moolenaar <Bram@vim.org>
parents: 19719
diff changeset
227 \ ' molestie eleifend condimentum, arcu ipsum congue',
26448
748793fcb4e2 patch 8.2.3754: undesired changing of the indent of the first formatted line
Bram Moolenaar <Bram@vim.org>
parents: 26167
diff changeset
228 \ ' nisl, quis euismod purus libero in ante.',
748793fcb4e2 patch 8.2.3754: undesired changing of the indent of the first formatted line
Bram Moolenaar <Bram@vim.org>
parents: 26167
diff changeset
229 \ '',
748793fcb4e2 patch 8.2.3754: undesired changing of the indent of the first formatted line
Bram Moolenaar <Bram@vim.org>
parents: 26167
diff changeset
230 \ ' Donec id semper purus. Suspendisse eget aliquam',
748793fcb4e2 patch 8.2.3754: undesired changing of the indent of the first formatted line
Bram Moolenaar <Bram@vim.org>
parents: 26167
diff changeset
231 \ ' nunc. Maecenas fringilla mauris vitae maximus',
26167
7108cee19a2c patch 8.2.3615: wrong indent in first line if re-formatting with indent expr
Bram Moolenaar <Bram@vim.org>
parents: 19719
diff changeset
232 \ ' condimentum. Cras a quam in mi dictum eleifend',
7108cee19a2c patch 8.2.3615: wrong indent in first line if re-formatting with indent expr
Bram Moolenaar <Bram@vim.org>
parents: 19719
diff changeset
233 \ ' at a lorem. Sed convallis ante a commodo',
7108cee19a2c patch 8.2.3615: wrong indent in first line if re-formatting with indent expr
Bram Moolenaar <Bram@vim.org>
parents: 19719
diff changeset
234 \ ' facilisis. Nam suscipit vulputate odio, vel',
7108cee19a2c patch 8.2.3615: wrong indent in first line if re-formatting with indent expr
Bram Moolenaar <Bram@vim.org>
parents: 19719
diff changeset
235 \ ' dapibus nisl dignissim facilisis. Vestibulum',
7108cee19a2c patch 8.2.3615: wrong indent in first line if re-formatting with indent expr
Bram Moolenaar <Bram@vim.org>
parents: 19719
diff changeset
236 \ ' ante ipsum primis in faucibus orci luctus et',
7108cee19a2c patch 8.2.3615: wrong indent in first line if re-formatting with indent expr
Bram Moolenaar <Bram@vim.org>
parents: 19719
diff changeset
237 \ ' ultrices posuere cubilia curae;', '', '']
7108cee19a2c patch 8.2.3615: wrong indent in first line if re-formatting with indent expr
Bram Moolenaar <Bram@vim.org>
parents: 19719
diff changeset
238 call assert_equal(expected, getline(1, '$'))
7108cee19a2c patch 8.2.3615: wrong indent in first line if re-formatting with indent expr
Bram Moolenaar <Bram@vim.org>
parents: 19719
diff changeset
239
7108cee19a2c patch 8.2.3615: wrong indent in first line if re-formatting with indent expr
Bram Moolenaar <Bram@vim.org>
parents: 19719
diff changeset
240 bwipe!
7108cee19a2c patch 8.2.3615: wrong indent in first line if re-formatting with indent expr
Bram Moolenaar <Bram@vim.org>
parents: 19719
diff changeset
241 delmark ab
7108cee19a2c patch 8.2.3615: wrong indent in first line if re-formatting with indent expr
Bram Moolenaar <Bram@vim.org>
parents: 19719
diff changeset
242 delfunction GetTeXIndent
7108cee19a2c patch 8.2.3615: wrong indent in first line if re-formatting with indent expr
Bram Moolenaar <Bram@vim.org>
parents: 19719
diff changeset
243 endfu
7108cee19a2c patch 8.2.3615: wrong indent in first line if re-formatting with indent expr
Bram Moolenaar <Bram@vim.org>
parents: 19719
diff changeset
244
26448
748793fcb4e2 patch 8.2.3754: undesired changing of the indent of the first formatted line
Bram Moolenaar <Bram@vim.org>
parents: 26167
diff changeset
245 func Test_formatting_keeps_first_line_indent()
748793fcb4e2 patch 8.2.3754: undesired changing of the indent of the first formatted line
Bram Moolenaar <Bram@vim.org>
parents: 26167
diff changeset
246 let lines =<< trim END
748793fcb4e2 patch 8.2.3754: undesired changing of the indent of the first formatted line
Bram Moolenaar <Bram@vim.org>
parents: 26167
diff changeset
247 foo()
748793fcb4e2 patch 8.2.3754: undesired changing of the indent of the first formatted line
Bram Moolenaar <Bram@vim.org>
parents: 26167
diff changeset
248 {
748793fcb4e2 patch 8.2.3754: undesired changing of the indent of the first formatted line
Bram Moolenaar <Bram@vim.org>
parents: 26167
diff changeset
249 int x; // manually positioned
748793fcb4e2 patch 8.2.3754: undesired changing of the indent of the first formatted line
Bram Moolenaar <Bram@vim.org>
parents: 26167
diff changeset
250 // more text that will be formatted
748793fcb4e2 patch 8.2.3754: undesired changing of the indent of the first formatted line
Bram Moolenaar <Bram@vim.org>
parents: 26167
diff changeset
251 // but not reindented
748793fcb4e2 patch 8.2.3754: undesired changing of the indent of the first formatted line
Bram Moolenaar <Bram@vim.org>
parents: 26167
diff changeset
252 END
748793fcb4e2 patch 8.2.3754: undesired changing of the indent of the first formatted line
Bram Moolenaar <Bram@vim.org>
parents: 26167
diff changeset
253 new
748793fcb4e2 patch 8.2.3754: undesired changing of the indent of the first formatted line
Bram Moolenaar <Bram@vim.org>
parents: 26167
diff changeset
254 call setline(1, lines)
748793fcb4e2 patch 8.2.3754: undesired changing of the indent of the first formatted line
Bram Moolenaar <Bram@vim.org>
parents: 26167
diff changeset
255 setlocal sw=4 cindent tw=45 et
748793fcb4e2 patch 8.2.3754: undesired changing of the indent of the first formatted line
Bram Moolenaar <Bram@vim.org>
parents: 26167
diff changeset
256 normal! 4Ggqj
748793fcb4e2 patch 8.2.3754: undesired changing of the indent of the first formatted line
Bram Moolenaar <Bram@vim.org>
parents: 26167
diff changeset
257 let expected =<< trim END
748793fcb4e2 patch 8.2.3754: undesired changing of the indent of the first formatted line
Bram Moolenaar <Bram@vim.org>
parents: 26167
diff changeset
258 foo()
748793fcb4e2 patch 8.2.3754: undesired changing of the indent of the first formatted line
Bram Moolenaar <Bram@vim.org>
parents: 26167
diff changeset
259 {
748793fcb4e2 patch 8.2.3754: undesired changing of the indent of the first formatted line
Bram Moolenaar <Bram@vim.org>
parents: 26167
diff changeset
260 int x; // manually positioned
748793fcb4e2 patch 8.2.3754: undesired changing of the indent of the first formatted line
Bram Moolenaar <Bram@vim.org>
parents: 26167
diff changeset
261 // more text that will be
748793fcb4e2 patch 8.2.3754: undesired changing of the indent of the first formatted line
Bram Moolenaar <Bram@vim.org>
parents: 26167
diff changeset
262 // formatted but not
748793fcb4e2 patch 8.2.3754: undesired changing of the indent of the first formatted line
Bram Moolenaar <Bram@vim.org>
parents: 26167
diff changeset
263 // reindented
748793fcb4e2 patch 8.2.3754: undesired changing of the indent of the first formatted line
Bram Moolenaar <Bram@vim.org>
parents: 26167
diff changeset
264 END
748793fcb4e2 patch 8.2.3754: undesired changing of the indent of the first formatted line
Bram Moolenaar <Bram@vim.org>
parents: 26167
diff changeset
265 call assert_equal(expected, getline(1, '$'))
748793fcb4e2 patch 8.2.3754: undesired changing of the indent of the first formatted line
Bram Moolenaar <Bram@vim.org>
parents: 26167
diff changeset
266 bwipe!
748793fcb4e2 patch 8.2.3754: undesired changing of the indent of the first formatted line
Bram Moolenaar <Bram@vim.org>
parents: 26167
diff changeset
267 endfunc
748793fcb4e2 patch 8.2.3754: undesired changing of the indent of the first formatted line
Bram Moolenaar <Bram@vim.org>
parents: 26167
diff changeset
268
19603
6d3c683466f4 patch 8.2.0358: insufficient testing for indent.c
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
269 " vim: shiftwidth=2 sts=2 expandtab