annotate src/testdir/test_retab.vim @ 34298:5525b635ed4a v9.1.0084

patch 9.1.0084: Visual hl wrong when it ends before multibyte 'showbreak' Commit: https://github.com/vim/vim/commit/df23d7f4bd7546f3152ea003856525591218565b Author: zeertzjq <zeertzjq@outlook.com> Date: Fri Feb 9 18:14:12 2024 +0100 patch 9.1.0084: Visual hl wrong when it ends before multibyte 'showbreak' Problem: Visual hl wrong when it ends before multibyte 'showbreak'. (lacygoil) Solution: Use vcol_sbr instead of adding n_extra. (zeertzjq) fixes: #11272 closes: #13996 Signed-off-by: zeertzjq <zeertzjq@outlook.com> Signed-off-by: Christian Brabandt <cb@256bit.org>
author Christian Brabandt <cb@256bit.org>
date Fri, 09 Feb 2024 18:30:04 +0100
parents 6a6c56354cfc
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
10633
91444fa276eb patch 8.0.0206: test coverage for :retab insufficient
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1 " Test :retab
21765
08940efa6b4e patch 8.2.1432: various inconsistencies in test files
Bram Moolenaar <Bram@vim.org>
parents: 10633
diff changeset
2
29169
0d74b4bb4970 patch 8.2.5104: test hangs on MS-Windows
Bram Moolenaar <Bram@vim.org>
parents: 29167
diff changeset
3 source check.vim
0d74b4bb4970 patch 8.2.5104: test hangs on MS-Windows
Bram Moolenaar <Bram@vim.org>
parents: 29167
diff changeset
4
10633
91444fa276eb patch 8.0.0206: test coverage for :retab insufficient
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5 func SetUp()
91444fa276eb patch 8.0.0206: test coverage for :retab insufficient
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6 new
91444fa276eb patch 8.0.0206: test coverage for :retab insufficient
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7 call setline(1, "\ta \t b c ")
91444fa276eb patch 8.0.0206: test coverage for :retab insufficient
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8 endfunc
91444fa276eb patch 8.0.0206: test coverage for :retab insufficient
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9
91444fa276eb patch 8.0.0206: test coverage for :retab insufficient
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10 func TearDown()
91444fa276eb patch 8.0.0206: test coverage for :retab insufficient
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
11 bwipe!
91444fa276eb patch 8.0.0206: test coverage for :retab insufficient
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
12 endfunc
91444fa276eb patch 8.0.0206: test coverage for :retab insufficient
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
13
91444fa276eb patch 8.0.0206: test coverage for :retab insufficient
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
14 func Retab(bang, n)
91444fa276eb patch 8.0.0206: test coverage for :retab insufficient
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
15 let l:old_tabstop = &tabstop
91444fa276eb patch 8.0.0206: test coverage for :retab insufficient
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
16 let l:old_line = getline(1)
91444fa276eb patch 8.0.0206: test coverage for :retab insufficient
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
17 exe "retab" . a:bang . a:n
91444fa276eb patch 8.0.0206: test coverage for :retab insufficient
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
18 let l:line = getline(1)
91444fa276eb patch 8.0.0206: test coverage for :retab insufficient
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
19 call setline(1, l:old_line)
91444fa276eb patch 8.0.0206: test coverage for :retab insufficient
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
20 if a:n > 0
91444fa276eb patch 8.0.0206: test coverage for :retab insufficient
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
21 " :retab changes 'tabstop' to n with argument n > 0.
91444fa276eb patch 8.0.0206: test coverage for :retab insufficient
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
22 call assert_equal(a:n, &tabstop)
91444fa276eb patch 8.0.0206: test coverage for :retab insufficient
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
23 exe 'set tabstop=' . l:old_tabstop
91444fa276eb patch 8.0.0206: test coverage for :retab insufficient
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
24 else
91444fa276eb patch 8.0.0206: test coverage for :retab insufficient
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
25 " :retab does not change 'tabstop' with empty or n <= 0.
91444fa276eb patch 8.0.0206: test coverage for :retab insufficient
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
26 call assert_equal(l:old_tabstop, &tabstop)
91444fa276eb patch 8.0.0206: test coverage for :retab insufficient
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
27 endif
91444fa276eb patch 8.0.0206: test coverage for :retab insufficient
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
28 return l:line
91444fa276eb patch 8.0.0206: test coverage for :retab insufficient
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
29 endfunc
91444fa276eb patch 8.0.0206: test coverage for :retab insufficient
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
30
91444fa276eb patch 8.0.0206: test coverage for :retab insufficient
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
31 func Test_retab()
91444fa276eb patch 8.0.0206: test coverage for :retab insufficient
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
32 set tabstop=8 noexpandtab
91444fa276eb patch 8.0.0206: test coverage for :retab insufficient
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
33 call assert_equal("\ta\t b c ", Retab('', ''))
91444fa276eb patch 8.0.0206: test coverage for :retab insufficient
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
34 call assert_equal("\ta\t b c ", Retab('', 0))
91444fa276eb patch 8.0.0206: test coverage for :retab insufficient
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
35 call assert_equal("\ta\t b c ", Retab('', 8))
91444fa276eb patch 8.0.0206: test coverage for :retab insufficient
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
36 call assert_equal("\ta\t b\t c\t ", Retab('!', ''))
91444fa276eb patch 8.0.0206: test coverage for :retab insufficient
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
37 call assert_equal("\ta\t b\t c\t ", Retab('!', 0))
91444fa276eb patch 8.0.0206: test coverage for :retab insufficient
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
38 call assert_equal("\ta\t b\t c\t ", Retab('!', 8))
91444fa276eb patch 8.0.0206: test coverage for :retab insufficient
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
39
91444fa276eb patch 8.0.0206: test coverage for :retab insufficient
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
40 call assert_equal("\t\ta\t\t\tb c ", Retab('', 4))
91444fa276eb patch 8.0.0206: test coverage for :retab insufficient
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
41 call assert_equal("\t\ta\t\t\tb\t\t c\t ", Retab('!', 4))
91444fa276eb patch 8.0.0206: test coverage for :retab insufficient
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
42
91444fa276eb patch 8.0.0206: test coverage for :retab insufficient
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
43 call assert_equal(" a\t\tb c ", Retab('', 10))
91444fa276eb patch 8.0.0206: test coverage for :retab insufficient
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
44 call assert_equal(" a\t\tb c ", Retab('!', 10))
91444fa276eb patch 8.0.0206: test coverage for :retab insufficient
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
45
91444fa276eb patch 8.0.0206: test coverage for :retab insufficient
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
46 set tabstop=8 expandtab
91444fa276eb patch 8.0.0206: test coverage for :retab insufficient
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
47 call assert_equal(" a b c ", Retab('', ''))
91444fa276eb patch 8.0.0206: test coverage for :retab insufficient
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
48 call assert_equal(" a b c ", Retab('', 0))
91444fa276eb patch 8.0.0206: test coverage for :retab insufficient
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
49 call assert_equal(" a b c ", Retab('', 8))
91444fa276eb patch 8.0.0206: test coverage for :retab insufficient
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
50 call assert_equal(" a b c ", Retab('!', ''))
91444fa276eb patch 8.0.0206: test coverage for :retab insufficient
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
51 call assert_equal(" a b c ", Retab('!', 0))
91444fa276eb patch 8.0.0206: test coverage for :retab insufficient
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
52 call assert_equal(" a b c ", Retab('!', 8))
91444fa276eb patch 8.0.0206: test coverage for :retab insufficient
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
53
91444fa276eb patch 8.0.0206: test coverage for :retab insufficient
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
54 call assert_equal(" a b c ", Retab(' ', 4))
91444fa276eb patch 8.0.0206: test coverage for :retab insufficient
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
55 call assert_equal(" a b c ", Retab('!', 4))
91444fa276eb patch 8.0.0206: test coverage for :retab insufficient
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
56
91444fa276eb patch 8.0.0206: test coverage for :retab insufficient
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
57 call assert_equal(" a b c ", Retab(' ', 10))
91444fa276eb patch 8.0.0206: test coverage for :retab insufficient
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
58 call assert_equal(" a b c ", Retab('!', 10))
91444fa276eb patch 8.0.0206: test coverage for :retab insufficient
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
59
91444fa276eb patch 8.0.0206: test coverage for :retab insufficient
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
60 set tabstop=4 noexpandtab
91444fa276eb patch 8.0.0206: test coverage for :retab insufficient
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
61 call assert_equal("\ta\t\tb c ", Retab('', ''))
91444fa276eb patch 8.0.0206: test coverage for :retab insufficient
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
62 call assert_equal("\ta\t\tb\t\t c\t ", Retab('!', ''))
91444fa276eb patch 8.0.0206: test coverage for :retab insufficient
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
63 call assert_equal("\t a\t\t\tb c ", Retab('', 3))
91444fa276eb patch 8.0.0206: test coverage for :retab insufficient
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
64 call assert_equal("\t a\t\t\tb\t\t\tc\t ", Retab('!', 3))
91444fa276eb patch 8.0.0206: test coverage for :retab insufficient
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
65 call assert_equal(" a\t b c ", Retab('', 5))
91444fa276eb patch 8.0.0206: test coverage for :retab insufficient
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
66 call assert_equal(" a\t b\t\t c\t ", Retab('!', 5))
91444fa276eb patch 8.0.0206: test coverage for :retab insufficient
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
67
91444fa276eb patch 8.0.0206: test coverage for :retab insufficient
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
68 set tabstop=4 expandtab
91444fa276eb patch 8.0.0206: test coverage for :retab insufficient
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
69 call assert_equal(" a b c ", Retab('', ''))
91444fa276eb patch 8.0.0206: test coverage for :retab insufficient
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
70 call assert_equal(" a b c ", Retab('!', ''))
91444fa276eb patch 8.0.0206: test coverage for :retab insufficient
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
71 call assert_equal(" a b c ", Retab('', 3))
91444fa276eb patch 8.0.0206: test coverage for :retab insufficient
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
72 call assert_equal(" a b c ", Retab('!', 3))
91444fa276eb patch 8.0.0206: test coverage for :retab insufficient
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
73 call assert_equal(" a b c ", Retab('', 5))
91444fa276eb patch 8.0.0206: test coverage for :retab insufficient
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
74 call assert_equal(" a b c ", Retab('!', 5))
27667
289e87a78307 patch 8.2.4359: crash when repeatedly using :retab
Bram Moolenaar <Bram@vim.org>
parents: 25733
diff changeset
75
289e87a78307 patch 8.2.4359: crash when repeatedly using :retab
Bram Moolenaar <Bram@vim.org>
parents: 25733
diff changeset
76 set tabstop& expandtab&
10633
91444fa276eb patch 8.0.0206: test coverage for :retab insufficient
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
77 endfunc
91444fa276eb patch 8.0.0206: test coverage for :retab insufficient
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
78
91444fa276eb patch 8.0.0206: test coverage for :retab insufficient
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
79 func Test_retab_error()
91444fa276eb patch 8.0.0206: test coverage for :retab insufficient
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
80 call assert_fails('retab -1', 'E487:')
91444fa276eb patch 8.0.0206: test coverage for :retab insufficient
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
81 call assert_fails('retab! -1', 'E487:')
25733
4b2616ffe32b patch 8.2.3402: invalid memory access when using :retab with large value
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
82 call assert_fails('ret -1000', 'E487:')
4b2616ffe32b patch 8.2.3402: invalid memory access when using :retab with large value
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
83 call assert_fails('ret 10000', 'E475:')
4b2616ffe32b patch 8.2.3402: invalid memory access when using :retab with large value
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
84 call assert_fails('ret 80000000000000000000', 'E475:')
10633
91444fa276eb patch 8.0.0206: test coverage for :retab insufficient
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
85 endfunc
21765
08940efa6b4e patch 8.2.1432: various inconsistencies in test files
Bram Moolenaar <Bram@vim.org>
parents: 10633
diff changeset
86
29165
0e0e298e05c1 patch 8.2.5102: interrupt not caught in test
Bram Moolenaar <Bram@vim.org>
parents: 29124
diff changeset
87 func RetabLoop()
0e0e298e05c1 patch 8.2.5102: interrupt not caught in test
Bram Moolenaar <Bram@vim.org>
parents: 29124
diff changeset
88 while 1
0e0e298e05c1 patch 8.2.5102: interrupt not caught in test
Bram Moolenaar <Bram@vim.org>
parents: 29124
diff changeset
89 set ts=4000
0e0e298e05c1 patch 8.2.5102: interrupt not caught in test
Bram Moolenaar <Bram@vim.org>
parents: 29124
diff changeset
90 retab 4
0e0e298e05c1 patch 8.2.5102: interrupt not caught in test
Bram Moolenaar <Bram@vim.org>
parents: 29124
diff changeset
91 endwhile
0e0e298e05c1 patch 8.2.5102: interrupt not caught in test
Bram Moolenaar <Bram@vim.org>
parents: 29124
diff changeset
92 endfunc
0e0e298e05c1 patch 8.2.5102: interrupt not caught in test
Bram Moolenaar <Bram@vim.org>
parents: 29124
diff changeset
93
0e0e298e05c1 patch 8.2.5102: interrupt not caught in test
Bram Moolenaar <Bram@vim.org>
parents: 29124
diff changeset
94 func Test_retab_endless()
29177
6a6c56354cfc patch 8.2.5108: retab test disabled because it hangs on MS-Windows
Bram Moolenaar <Bram@vim.org>
parents: 29171
diff changeset
95 " inside try/catch we can catch the error message
27667
289e87a78307 patch 8.2.4359: crash when repeatedly using :retab
Bram Moolenaar <Bram@vim.org>
parents: 25733
diff changeset
96 call setline(1, "\t0\t")
289e87a78307 patch 8.2.4359: crash when repeatedly using :retab
Bram Moolenaar <Bram@vim.org>
parents: 25733
diff changeset
97 let caught = 'no'
289e87a78307 patch 8.2.4359: crash when repeatedly using :retab
Bram Moolenaar <Bram@vim.org>
parents: 25733
diff changeset
98 try
29165
0e0e298e05c1 patch 8.2.5102: interrupt not caught in test
Bram Moolenaar <Bram@vim.org>
parents: 29124
diff changeset
99 call RetabLoop()
0e0e298e05c1 patch 8.2.5102: interrupt not caught in test
Bram Moolenaar <Bram@vim.org>
parents: 29124
diff changeset
100 catch /E1240:/
29124
fc0a70812f24 patch 8.2.5082: retab test fails
Bram Moolenaar <Bram@vim.org>
parents: 27667
diff changeset
101 let caught = v:exception
27667
289e87a78307 patch 8.2.4359: crash when repeatedly using :retab
Bram Moolenaar <Bram@vim.org>
parents: 25733
diff changeset
102 endtry
29165
0e0e298e05c1 patch 8.2.5102: interrupt not caught in test
Bram Moolenaar <Bram@vim.org>
parents: 29124
diff changeset
103 call assert_match('E1240:', caught)
29171
72140c10875f patch 8.2.5105: test still hangs on MS-Windows
Bram Moolenaar <Bram@vim.org>
parents: 29169
diff changeset
104
29165
0e0e298e05c1 patch 8.2.5102: interrupt not caught in test
Bram Moolenaar <Bram@vim.org>
parents: 29124
diff changeset
105 set tabstop&
0e0e298e05c1 patch 8.2.5102: interrupt not caught in test
Bram Moolenaar <Bram@vim.org>
parents: 29124
diff changeset
106 endfunc
0e0e298e05c1 patch 8.2.5102: interrupt not caught in test
Bram Moolenaar <Bram@vim.org>
parents: 29124
diff changeset
107
0e0e298e05c1 patch 8.2.5102: interrupt not caught in test
Bram Moolenaar <Bram@vim.org>
parents: 29124
diff changeset
108 func Test_nocatch_retab_endless()
29177
6a6c56354cfc patch 8.2.5108: retab test disabled because it hangs on MS-Windows
Bram Moolenaar <Bram@vim.org>
parents: 29171
diff changeset
109 " when not inside try/catch an interrupt is generated to get out of loops
29165
0e0e298e05c1 patch 8.2.5102: interrupt not caught in test
Bram Moolenaar <Bram@vim.org>
parents: 29124
diff changeset
110 call setline(1, "\t0\t")
0e0e298e05c1 patch 8.2.5102: interrupt not caught in test
Bram Moolenaar <Bram@vim.org>
parents: 29124
diff changeset
111 call assert_fails('call RetabLoop()', ['E1240:', 'Interrupted'])
0e0e298e05c1 patch 8.2.5102: interrupt not caught in test
Bram Moolenaar <Bram@vim.org>
parents: 29124
diff changeset
112
27667
289e87a78307 patch 8.2.4359: crash when repeatedly using :retab
Bram Moolenaar <Bram@vim.org>
parents: 25733
diff changeset
113 set tabstop&
289e87a78307 patch 8.2.4359: crash when repeatedly using :retab
Bram Moolenaar <Bram@vim.org>
parents: 25733
diff changeset
114 endfunc
289e87a78307 patch 8.2.4359: crash when repeatedly using :retab
Bram Moolenaar <Bram@vim.org>
parents: 25733
diff changeset
115
289e87a78307 patch 8.2.4359: crash when repeatedly using :retab
Bram Moolenaar <Bram@vim.org>
parents: 25733
diff changeset
116
21765
08940efa6b4e patch 8.2.1432: various inconsistencies in test files
Bram Moolenaar <Bram@vim.org>
parents: 10633
diff changeset
117 " vim: shiftwidth=2 sts=2 expandtab