Mercurial > vim
annotate src/testdir/test_indent.vim @ 33944:4cacac1abdb8
runtime(termdebug): add Tbreak command
Commit: https://github.com/vim/vim/commit/323dda1484d95ee5c8a1b2205f8c495446df75ee
Author: iam28th <artyom28th@gmail.com>
Date: Thu Dec 14 20:30:26 2023 +0100
runtime(termdebug): add Tbreak command
closes: https://github.com/vim/vim/issues/13656
Signed-off-by: iam28th <artyom28th@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Thu, 14 Dec 2023 20:45:03 +0100 |
parents | 2e92551b2350 |
children |
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 |
29206
a2c89e5446b7
patch 8.2.5122: lisp indenting my run over the end of the line
Bram Moolenaar <Bram@vim.org>
parents:
28536
diff
changeset
|
147 func Test_lisp_indent_quoted() |
a2c89e5446b7
patch 8.2.5122: lisp indenting my run over the end of the line
Bram Moolenaar <Bram@vim.org>
parents:
28536
diff
changeset
|
148 " This was going past the end of the line |
a2c89e5446b7
patch 8.2.5122: lisp indenting my run over the end of the line
Bram Moolenaar <Bram@vim.org>
parents:
28536
diff
changeset
|
149 new |
a2c89e5446b7
patch 8.2.5122: lisp indenting my run over the end of the line
Bram Moolenaar <Bram@vim.org>
parents:
28536
diff
changeset
|
150 setlocal lisp autoindent |
a2c89e5446b7
patch 8.2.5122: lisp indenting my run over the end of the line
Bram Moolenaar <Bram@vim.org>
parents:
28536
diff
changeset
|
151 call setline(1, ['"[', '=']) |
a2c89e5446b7
patch 8.2.5122: lisp indenting my run over the end of the line
Bram Moolenaar <Bram@vim.org>
parents:
28536
diff
changeset
|
152 normal Gvk= |
a2c89e5446b7
patch 8.2.5122: lisp indenting my run over the end of the line
Bram Moolenaar <Bram@vim.org>
parents:
28536
diff
changeset
|
153 |
a2c89e5446b7
patch 8.2.5122: lisp indenting my run over the end of the line
Bram Moolenaar <Bram@vim.org>
parents:
28536
diff
changeset
|
154 bwipe! |
a2c89e5446b7
patch 8.2.5122: lisp indenting my run over the end of the line
Bram Moolenaar <Bram@vim.org>
parents:
28536
diff
changeset
|
155 endfunc |
a2c89e5446b7
patch 8.2.5122: lisp indenting my run over the end of the line
Bram Moolenaar <Bram@vim.org>
parents:
28536
diff
changeset
|
156 |
19613
9c15be376631
patch 8.2.0363: some Normal mode commands not tested
Bram Moolenaar <Bram@vim.org>
parents:
19603
diff
changeset
|
157 " 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
|
158 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
|
159 let modeline = &modeline |
9c15be376631
patch 8.2.0363: some Normal mode commands not tested
Bram Moolenaar <Bram@vim.org>
parents:
19603
diff
changeset
|
160 set modeline |
9c15be376631
patch 8.2.0363: some Normal mode commands not tested
Bram Moolenaar <Bram@vim.org>
parents:
19603
diff
changeset
|
161 func GetIndent() |
9c15be376631
patch 8.2.0363: some Normal mode commands not tested
Bram Moolenaar <Bram@vim.org>
parents:
19603
diff
changeset
|
162 return line('.') * 2 |
9c15be376631
patch 8.2.0363: some Normal mode commands not tested
Bram Moolenaar <Bram@vim.org>
parents:
19603
diff
changeset
|
163 endfunc |
30580
f08ed0738f7a
patch 9.0.0625: too many delete() calls in tests
Bram Moolenaar <Bram@vim.org>
parents:
30051
diff
changeset
|
164 call writefile(['# vim: indentexpr=GetIndent()'], 'Xmlfile.txt', 'D') |
19613
9c15be376631
patch 8.2.0363: some Normal mode commands not tested
Bram Moolenaar <Bram@vim.org>
parents:
19603
diff
changeset
|
165 set modelineexpr |
30051
13b02c1ea0f7
patch 9.0.0363: common names in test files causes tests to be flaky
Bram Moolenaar <Bram@vim.org>
parents:
29206
diff
changeset
|
166 new Xmlfile.txt |
19613
9c15be376631
patch 8.2.0363: some Normal mode commands not tested
Bram Moolenaar <Bram@vim.org>
parents:
19603
diff
changeset
|
167 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
|
168 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
|
169 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
|
170 |
19613
9c15be376631
patch 8.2.0363: some Normal mode commands not tested
Bram Moolenaar <Bram@vim.org>
parents:
19603
diff
changeset
|
171 set modelineexpr& |
9c15be376631
patch 8.2.0363: some Normal mode commands not tested
Bram Moolenaar <Bram@vim.org>
parents:
19603
diff
changeset
|
172 delfunc GetIndent |
9c15be376631
patch 8.2.0363: some Normal mode commands not tested
Bram Moolenaar <Bram@vim.org>
parents:
19603
diff
changeset
|
173 let &modeline = modeline |
9c15be376631
patch 8.2.0363: some Normal mode commands not tested
Bram Moolenaar <Bram@vim.org>
parents:
19603
diff
changeset
|
174 close! |
9c15be376631
patch 8.2.0363: some Normal mode commands not tested
Bram Moolenaar <Bram@vim.org>
parents:
19603
diff
changeset
|
175 endfunc |
9c15be376631
patch 8.2.0363: some Normal mode commands not tested
Bram Moolenaar <Bram@vim.org>
parents:
19603
diff
changeset
|
176 |
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
|
177 func Test_indent_func_with_gq() |
31849
dbec60b8c253
patch 9.0.1257: code style is not check in test scripts
Bram Moolenaar <Bram@vim.org>
parents:
30580
diff
changeset
|
178 |
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
|
179 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
|
180 " 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
|
181 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
|
182 " 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
|
183 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
|
184 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
|
185 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
|
186 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
|
187 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
|
188 " Add a 'shiftwidth' after beginning of environments. |
31849
dbec60b8c253
patch 9.0.1257: code style is not check in test scripts
Bram Moolenaar <Bram@vim.org>
parents:
30580
diff
changeset
|
189 if line =~ '\\begin{center}' |
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
|
190 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
|
191 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
|
192 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
|
193 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
|
194 |
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 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
|
196 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
|
197 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
|
198 \ '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
|
199 \ '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
|
200 \ '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
|
201 \ '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
|
202 \ '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
|
203 \ '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
|
204 \ '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
|
205 \ '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
|
206 \ '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
|
207 \ '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
|
208 \ '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
|
209 \ '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
|
210 \ '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
|
211 \ '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
|
212 \ '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
|
213 \ '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
|
214 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
|
215 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
|
216 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
|
217 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
|
218 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
|
219 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
|
220 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
|
221 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
|
222 \ '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
|
223 \ '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
|
224 \ '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
|
225 \ '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
|
226 \ '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
|
227 \ '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
|
228 \ '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
|
229 \ '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
|
230 \ '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
|
231 \ '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
|
232 \ '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
|
233 \ ' 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
|
234 \ ' 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
|
235 \ ' 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
|
236 \ ' 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
|
237 \ ' 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
|
238 \ '', |
748793fcb4e2
patch 8.2.3754: undesired changing of the indent of the first formatted line
Bram Moolenaar <Bram@vim.org>
parents:
26167
diff
changeset
|
239 \ ' 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
|
240 \ ' 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
|
241 \ ' 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
|
242 \ ' 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
|
243 \ ' 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
|
244 \ ' 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
|
245 \ ' 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
|
246 \ ' 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
|
247 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
|
248 |
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
|
249 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
|
250 delmark ab |
31849
dbec60b8c253
patch 9.0.1257: code style is not check in test scripts
Bram Moolenaar <Bram@vim.org>
parents:
30580
diff
changeset
|
251 delfunction GetTeXIndent |
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
|
252 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
|
253 |
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
|
254 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
|
255 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
|
256 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
|
257 { |
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 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
|
259 // 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
|
260 // 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
|
261 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
|
262 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
|
263 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
|
264 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
|
265 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
|
266 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
|
267 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
|
268 { |
748793fcb4e2
patch 8.2.3754: undesired changing of the indent of the first formatted line
Bram Moolenaar <Bram@vim.org>
parents:
26167
diff
changeset
|
269 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
|
270 // 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
|
271 // 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
|
272 // 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
|
273 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
|
274 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
|
275 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
|
276 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
|
277 |
33784
872c07d5befe
patch 9.0.2112: [security]: overflow in shift_line
Christian Brabandt <cb@256bit.org>
parents:
31849
diff
changeset
|
278 " Test for indenting with large amount, causes overflow |
872c07d5befe
patch 9.0.2112: [security]: overflow in shift_line
Christian Brabandt <cb@256bit.org>
parents:
31849
diff
changeset
|
279 func Test_indent_overflow_count() |
872c07d5befe
patch 9.0.2112: [security]: overflow in shift_line
Christian Brabandt <cb@256bit.org>
parents:
31849
diff
changeset
|
280 new |
872c07d5befe
patch 9.0.2112: [security]: overflow in shift_line
Christian Brabandt <cb@256bit.org>
parents:
31849
diff
changeset
|
281 setl sw=8 |
872c07d5befe
patch 9.0.2112: [security]: overflow in shift_line
Christian Brabandt <cb@256bit.org>
parents:
31849
diff
changeset
|
282 call setline(1, "abc") |
872c07d5befe
patch 9.0.2112: [security]: overflow in shift_line
Christian Brabandt <cb@256bit.org>
parents:
31849
diff
changeset
|
283 norm! V2147483647> |
872c07d5befe
patch 9.0.2112: [security]: overflow in shift_line
Christian Brabandt <cb@256bit.org>
parents:
31849
diff
changeset
|
284 " indents by INT_MAX |
872c07d5befe
patch 9.0.2112: [security]: overflow in shift_line
Christian Brabandt <cb@256bit.org>
parents:
31849
diff
changeset
|
285 call assert_equal(2147483647, indent(1)) |
872c07d5befe
patch 9.0.2112: [security]: overflow in shift_line
Christian Brabandt <cb@256bit.org>
parents:
31849
diff
changeset
|
286 close! |
872c07d5befe
patch 9.0.2112: [security]: overflow in shift_line
Christian Brabandt <cb@256bit.org>
parents:
31849
diff
changeset
|
287 endfunc |
872c07d5befe
patch 9.0.2112: [security]: overflow in shift_line
Christian Brabandt <cb@256bit.org>
parents:
31849
diff
changeset
|
288 |
33813
2e92551b2350
patch 9.0.2122: [security]: prevent overflow in indenting
Christian Brabandt <cb@256bit.org>
parents:
33784
diff
changeset
|
289 func Test_indent_overflow_count2() |
2e92551b2350
patch 9.0.2122: [security]: prevent overflow in indenting
Christian Brabandt <cb@256bit.org>
parents:
33784
diff
changeset
|
290 new |
2e92551b2350
patch 9.0.2122: [security]: prevent overflow in indenting
Christian Brabandt <cb@256bit.org>
parents:
33784
diff
changeset
|
291 " this only works, when long is 64bits |
2e92551b2350
patch 9.0.2122: [security]: prevent overflow in indenting
Christian Brabandt <cb@256bit.org>
parents:
33784
diff
changeset
|
292 try |
2e92551b2350
patch 9.0.2122: [security]: prevent overflow in indenting
Christian Brabandt <cb@256bit.org>
parents:
33784
diff
changeset
|
293 setl sw=0x180000000 |
2e92551b2350
patch 9.0.2122: [security]: prevent overflow in indenting
Christian Brabandt <cb@256bit.org>
parents:
33784
diff
changeset
|
294 catch /^Vim\%((\a\+)\)\=:E487:/ |
2e92551b2350
patch 9.0.2122: [security]: prevent overflow in indenting
Christian Brabandt <cb@256bit.org>
parents:
33784
diff
changeset
|
295 throw 'Skipped: value negative on this platform' |
2e92551b2350
patch 9.0.2122: [security]: prevent overflow in indenting
Christian Brabandt <cb@256bit.org>
parents:
33784
diff
changeset
|
296 endtry |
2e92551b2350
patch 9.0.2122: [security]: prevent overflow in indenting
Christian Brabandt <cb@256bit.org>
parents:
33784
diff
changeset
|
297 call setline(1, "\tabc") |
2e92551b2350
patch 9.0.2122: [security]: prevent overflow in indenting
Christian Brabandt <cb@256bit.org>
parents:
33784
diff
changeset
|
298 norm! << |
2e92551b2350
patch 9.0.2122: [security]: prevent overflow in indenting
Christian Brabandt <cb@256bit.org>
parents:
33784
diff
changeset
|
299 call assert_equal(0, indent(1)) |
2e92551b2350
patch 9.0.2122: [security]: prevent overflow in indenting
Christian Brabandt <cb@256bit.org>
parents:
33784
diff
changeset
|
300 close! |
2e92551b2350
patch 9.0.2122: [security]: prevent overflow in indenting
Christian Brabandt <cb@256bit.org>
parents:
33784
diff
changeset
|
301 endfunc |
2e92551b2350
patch 9.0.2122: [security]: prevent overflow in indenting
Christian Brabandt <cb@256bit.org>
parents:
33784
diff
changeset
|
302 |
19603
6d3c683466f4
patch 8.2.0358: insufficient testing for indent.c
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
303 " vim: shiftwidth=2 sts=2 expandtab |