Bram Moolenaar | 6c89686 | 2016-11-17 19:46:51 +0100 | [diff] [blame] | 1 | " Test for breakindent |
| 2 | " |
| 3 | " Note: if you get strange failures when adding new tests, it might be that |
Bram Moolenaar | 4b96df5 | 2020-01-26 22:00:26 +0100 | [diff] [blame] | 4 | " while the test is run, the breakindent caching gets in its way. |
Bram Moolenaar | 544d3bc | 2017-02-05 21:14:50 +0100 | [diff] [blame] | 5 | " It helps to change the tabstop setting and force a redraw (e.g. see |
Bram Moolenaar | 6c89686 | 2016-11-17 19:46:51 +0100 | [diff] [blame] | 6 | " Test_breakindent08()) |
Bram Moolenaar | 8c5a278 | 2019-08-07 23:07:07 +0200 | [diff] [blame] | 7 | source check.vim |
| 8 | CheckOption breakindent |
Bram Moolenaar | 6c89686 | 2016-11-17 19:46:51 +0100 | [diff] [blame] | 9 | |
Bram Moolenaar | 544d3bc | 2017-02-05 21:14:50 +0100 | [diff] [blame] | 10 | source view_util.vim |
| 11 | |
Bram Moolenaar | 6c89686 | 2016-11-17 19:46:51 +0100 | [diff] [blame] | 12 | let s:input ="\tabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOP" |
| 13 | |
Bram Moolenaar | 04958cb | 2018-06-23 19:23:02 +0200 | [diff] [blame] | 14 | func s:screen_lines(lnum, width) abort |
Bram Moolenaar | 544d3bc | 2017-02-05 21:14:50 +0100 | [diff] [blame] | 15 | return ScreenLines([a:lnum, a:lnum + 2], a:width) |
Bram Moolenaar | 04958cb | 2018-06-23 19:23:02 +0200 | [diff] [blame] | 16 | endfunc |
Bram Moolenaar | 6c89686 | 2016-11-17 19:46:51 +0100 | [diff] [blame] | 17 | |
Christian Brabandt | 4a0b85a | 2021-07-14 20:00:27 +0200 | [diff] [blame] | 18 | func s:screen_lines2(lnums, lnume, width) abort |
| 19 | return ScreenLines([a:lnums, a:lnume], a:width) |
| 20 | endfunc |
| 21 | |
Bram Moolenaar | 04958cb | 2018-06-23 19:23:02 +0200 | [diff] [blame] | 22 | func s:compare_lines(expect, actual) |
Bram Moolenaar | 544d3bc | 2017-02-05 21:14:50 +0100 | [diff] [blame] | 23 | call assert_equal(join(a:expect, "\n"), join(a:actual, "\n")) |
Bram Moolenaar | 04958cb | 2018-06-23 19:23:02 +0200 | [diff] [blame] | 24 | endfunc |
Bram Moolenaar | 544d3bc | 2017-02-05 21:14:50 +0100 | [diff] [blame] | 25 | |
Bram Moolenaar | 04958cb | 2018-06-23 19:23:02 +0200 | [diff] [blame] | 26 | func s:test_windows(...) |
Bram Moolenaar | 544d3bc | 2017-02-05 21:14:50 +0100 | [diff] [blame] | 27 | call NewWindow(10, 20) |
| 28 | setl ts=4 sw=4 sts=4 breakindent |
Bram Moolenaar | 6c89686 | 2016-11-17 19:46:51 +0100 | [diff] [blame] | 29 | put =s:input |
Bram Moolenaar | 544d3bc | 2017-02-05 21:14:50 +0100 | [diff] [blame] | 30 | exe get(a:000, 0, '') |
Bram Moolenaar | 04958cb | 2018-06-23 19:23:02 +0200 | [diff] [blame] | 31 | endfunc |
Bram Moolenaar | 6c89686 | 2016-11-17 19:46:51 +0100 | [diff] [blame] | 32 | |
Bram Moolenaar | 04958cb | 2018-06-23 19:23:02 +0200 | [diff] [blame] | 33 | func s:close_windows(...) |
Bram Moolenaar | 544d3bc | 2017-02-05 21:14:50 +0100 | [diff] [blame] | 34 | call CloseWindow() |
| 35 | exe get(a:000, 0, '') |
Bram Moolenaar | 04958cb | 2018-06-23 19:23:02 +0200 | [diff] [blame] | 36 | endfunc |
Bram Moolenaar | 6c89686 | 2016-11-17 19:46:51 +0100 | [diff] [blame] | 37 | |
Bram Moolenaar | 04958cb | 2018-06-23 19:23:02 +0200 | [diff] [blame] | 38 | func Test_breakindent01() |
Bram Moolenaar | 6c89686 | 2016-11-17 19:46:51 +0100 | [diff] [blame] | 39 | " simple breakindent test |
Bram Moolenaar | 544d3bc | 2017-02-05 21:14:50 +0100 | [diff] [blame] | 40 | call s:test_windows('setl briopt=min:0') |
Bram Moolenaar | 04958cb | 2018-06-23 19:23:02 +0200 | [diff] [blame] | 41 | let lines = s:screen_lines(line('.'),8) |
| 42 | let expect = [ |
| 43 | \ " abcd", |
| 44 | \ " qrst", |
| 45 | \ " GHIJ", |
| 46 | \ ] |
Bram Moolenaar | 544d3bc | 2017-02-05 21:14:50 +0100 | [diff] [blame] | 47 | call s:compare_lines(expect, lines) |
Bram Moolenaar | 6c89686 | 2016-11-17 19:46:51 +0100 | [diff] [blame] | 48 | call s:close_windows() |
Bram Moolenaar | 04958cb | 2018-06-23 19:23:02 +0200 | [diff] [blame] | 49 | endfunc |
Bram Moolenaar | 6c89686 | 2016-11-17 19:46:51 +0100 | [diff] [blame] | 50 | |
Bram Moolenaar | 04958cb | 2018-06-23 19:23:02 +0200 | [diff] [blame] | 51 | func Test_breakindent01_vartabs() |
| 52 | " like 01 but with vartabs feature |
Bram Moolenaar | 6d91bcb | 2020-08-12 18:50:36 +0200 | [diff] [blame] | 53 | CheckFeature vartabs |
Bram Moolenaar | 04958cb | 2018-06-23 19:23:02 +0200 | [diff] [blame] | 54 | call s:test_windows('setl briopt=min:0 vts=4') |
| 55 | let lines = s:screen_lines(line('.'),8) |
| 56 | let expect = [ |
| 57 | \ " abcd", |
| 58 | \ " qrst", |
| 59 | \ " GHIJ", |
| 60 | \ ] |
| 61 | call s:compare_lines(expect, lines) |
| 62 | call s:close_windows('set vts&') |
| 63 | endfunc |
| 64 | |
| 65 | func Test_breakindent02() |
Bram Moolenaar | 6c89686 | 2016-11-17 19:46:51 +0100 | [diff] [blame] | 66 | " simple breakindent test with showbreak set |
Bram Moolenaar | ee85702 | 2019-11-09 23:26:40 +0100 | [diff] [blame] | 67 | set sbr=>> |
| 68 | call s:test_windows('setl briopt=min:0 sbr=') |
Bram Moolenaar | 04958cb | 2018-06-23 19:23:02 +0200 | [diff] [blame] | 69 | let lines = s:screen_lines(line('.'),8) |
| 70 | let expect = [ |
| 71 | \ " abcd", |
| 72 | \ " >>qr", |
| 73 | \ " >>EF", |
| 74 | \ ] |
Bram Moolenaar | 544d3bc | 2017-02-05 21:14:50 +0100 | [diff] [blame] | 75 | call s:compare_lines(expect, lines) |
Bram Moolenaar | 6c89686 | 2016-11-17 19:46:51 +0100 | [diff] [blame] | 76 | call s:close_windows('set sbr=') |
Bram Moolenaar | 04958cb | 2018-06-23 19:23:02 +0200 | [diff] [blame] | 77 | endfunc |
Bram Moolenaar | 6c89686 | 2016-11-17 19:46:51 +0100 | [diff] [blame] | 78 | |
Bram Moolenaar | 04958cb | 2018-06-23 19:23:02 +0200 | [diff] [blame] | 79 | func Test_breakindent02_vartabs() |
Bram Moolenaar | 6d91bcb | 2020-08-12 18:50:36 +0200 | [diff] [blame] | 80 | CheckFeature vartabs |
Bram Moolenaar | 04958cb | 2018-06-23 19:23:02 +0200 | [diff] [blame] | 81 | " simple breakindent test with showbreak set |
| 82 | call s:test_windows('setl briopt=min:0 sbr=>> vts=4') |
| 83 | let lines = s:screen_lines(line('.'),8) |
| 84 | let expect = [ |
| 85 | \ " abcd", |
| 86 | \ " >>qr", |
| 87 | \ " >>EF", |
| 88 | \ ] |
| 89 | call s:compare_lines(expect, lines) |
| 90 | call s:close_windows('set sbr= vts&') |
| 91 | endfunc |
| 92 | |
| 93 | func Test_breakindent03() |
Bram Moolenaar | 6c89686 | 2016-11-17 19:46:51 +0100 | [diff] [blame] | 94 | " simple breakindent test with showbreak set and briopt including sbr |
Bram Moolenaar | 544d3bc | 2017-02-05 21:14:50 +0100 | [diff] [blame] | 95 | call s:test_windows('setl briopt=sbr,min:0 sbr=++') |
Bram Moolenaar | 04958cb | 2018-06-23 19:23:02 +0200 | [diff] [blame] | 96 | let lines = s:screen_lines(line('.'),8) |
| 97 | let expect = [ |
| 98 | \ " abcd", |
| 99 | \ "++ qrst", |
| 100 | \ "++ GHIJ", |
| 101 | \ ] |
Bram Moolenaar | 544d3bc | 2017-02-05 21:14:50 +0100 | [diff] [blame] | 102 | call s:compare_lines(expect, lines) |
Bram Moolenaar | 6c89686 | 2016-11-17 19:46:51 +0100 | [diff] [blame] | 103 | " clean up |
| 104 | call s:close_windows('set sbr=') |
Bram Moolenaar | 04958cb | 2018-06-23 19:23:02 +0200 | [diff] [blame] | 105 | endfunc |
Bram Moolenaar | 6c89686 | 2016-11-17 19:46:51 +0100 | [diff] [blame] | 106 | |
Bram Moolenaar | 04958cb | 2018-06-23 19:23:02 +0200 | [diff] [blame] | 107 | func Test_breakindent03_vartabs() |
| 108 | " simple breakindent test with showbreak set and briopt including sbr |
Bram Moolenaar | 6d91bcb | 2020-08-12 18:50:36 +0200 | [diff] [blame] | 109 | CheckFeature vartabs |
Bram Moolenaar | 04958cb | 2018-06-23 19:23:02 +0200 | [diff] [blame] | 110 | call s:test_windows('setl briopt=sbr,min:0 sbr=++ vts=4') |
| 111 | let lines = s:screen_lines(line('.'),8) |
| 112 | let expect = [ |
| 113 | \ " abcd", |
| 114 | \ "++ qrst", |
| 115 | \ "++ GHIJ", |
| 116 | \ ] |
| 117 | call s:compare_lines(expect, lines) |
| 118 | " clean up |
| 119 | call s:close_windows('set sbr= vts&') |
| 120 | endfunc |
| 121 | |
| 122 | func Test_breakindent04() |
Bram Moolenaar | 6c89686 | 2016-11-17 19:46:51 +0100 | [diff] [blame] | 123 | " breakindent set with min width 18 |
Bram Moolenaar | ee85702 | 2019-11-09 23:26:40 +0100 | [diff] [blame] | 124 | set sbr=<<< |
| 125 | call s:test_windows('setl sbr=NONE briopt=min:18') |
Bram Moolenaar | 04958cb | 2018-06-23 19:23:02 +0200 | [diff] [blame] | 126 | let lines = s:screen_lines(line('.'),8) |
| 127 | let expect = [ |
| 128 | \ " abcd", |
| 129 | \ " qrstuv", |
| 130 | \ " IJKLMN", |
| 131 | \ ] |
Bram Moolenaar | 544d3bc | 2017-02-05 21:14:50 +0100 | [diff] [blame] | 132 | call s:compare_lines(expect, lines) |
Bram Moolenaar | 6c89686 | 2016-11-17 19:46:51 +0100 | [diff] [blame] | 133 | " clean up |
| 134 | call s:close_windows('set sbr=') |
Bram Moolenaar | ee85702 | 2019-11-09 23:26:40 +0100 | [diff] [blame] | 135 | set sbr= |
Bram Moolenaar | 04958cb | 2018-06-23 19:23:02 +0200 | [diff] [blame] | 136 | endfunc |
Bram Moolenaar | 6c89686 | 2016-11-17 19:46:51 +0100 | [diff] [blame] | 137 | |
Bram Moolenaar | 04958cb | 2018-06-23 19:23:02 +0200 | [diff] [blame] | 138 | func Test_breakindent04_vartabs() |
| 139 | " breakindent set with min width 18 |
Bram Moolenaar | 6d91bcb | 2020-08-12 18:50:36 +0200 | [diff] [blame] | 140 | CheckFeature vartabs |
Bram Moolenaar | 04958cb | 2018-06-23 19:23:02 +0200 | [diff] [blame] | 141 | call s:test_windows('setl sbr= briopt=min:18 vts=4') |
| 142 | let lines = s:screen_lines(line('.'),8) |
| 143 | let expect = [ |
| 144 | \ " abcd", |
| 145 | \ " qrstuv", |
| 146 | \ " IJKLMN", |
| 147 | \ ] |
| 148 | call s:compare_lines(expect, lines) |
| 149 | " clean up |
| 150 | call s:close_windows('set sbr= vts&') |
| 151 | endfunc |
| 152 | |
| 153 | func Test_breakindent05() |
Bram Moolenaar | 6c89686 | 2016-11-17 19:46:51 +0100 | [diff] [blame] | 154 | " breakindent set and shift by 2 |
Bram Moolenaar | 544d3bc | 2017-02-05 21:14:50 +0100 | [diff] [blame] | 155 | call s:test_windows('setl briopt=shift:2,min:0') |
Bram Moolenaar | 04958cb | 2018-06-23 19:23:02 +0200 | [diff] [blame] | 156 | let lines = s:screen_lines(line('.'),8) |
| 157 | let expect = [ |
| 158 | \ " abcd", |
| 159 | \ " qr", |
| 160 | \ " EF", |
| 161 | \ ] |
Bram Moolenaar | 544d3bc | 2017-02-05 21:14:50 +0100 | [diff] [blame] | 162 | call s:compare_lines(expect, lines) |
Bram Moolenaar | 6c89686 | 2016-11-17 19:46:51 +0100 | [diff] [blame] | 163 | call s:close_windows() |
Bram Moolenaar | 04958cb | 2018-06-23 19:23:02 +0200 | [diff] [blame] | 164 | endfunc |
Bram Moolenaar | 6c89686 | 2016-11-17 19:46:51 +0100 | [diff] [blame] | 165 | |
Bram Moolenaar | 04958cb | 2018-06-23 19:23:02 +0200 | [diff] [blame] | 166 | func Test_breakindent05_vartabs() |
| 167 | " breakindent set and shift by 2 |
Bram Moolenaar | 6d91bcb | 2020-08-12 18:50:36 +0200 | [diff] [blame] | 168 | CheckFeature vartabs |
Bram Moolenaar | 04958cb | 2018-06-23 19:23:02 +0200 | [diff] [blame] | 169 | call s:test_windows('setl briopt=shift:2,min:0 vts=4') |
| 170 | let lines = s:screen_lines(line('.'),8) |
| 171 | let expect = [ |
| 172 | \ " abcd", |
| 173 | \ " qr", |
| 174 | \ " EF", |
| 175 | \ ] |
| 176 | call s:compare_lines(expect, lines) |
| 177 | call s:close_windows('set vts&') |
| 178 | endfunc |
| 179 | |
| 180 | func Test_breakindent06() |
Bram Moolenaar | 6c89686 | 2016-11-17 19:46:51 +0100 | [diff] [blame] | 181 | " breakindent set and shift by -1 |
Bram Moolenaar | 544d3bc | 2017-02-05 21:14:50 +0100 | [diff] [blame] | 182 | call s:test_windows('setl briopt=shift:-1,min:0') |
Bram Moolenaar | 04958cb | 2018-06-23 19:23:02 +0200 | [diff] [blame] | 183 | let lines = s:screen_lines(line('.'),8) |
| 184 | let expect = [ |
| 185 | \ " abcd", |
| 186 | \ " qrstu", |
| 187 | \ " HIJKL", |
| 188 | \ ] |
Bram Moolenaar | 544d3bc | 2017-02-05 21:14:50 +0100 | [diff] [blame] | 189 | call s:compare_lines(expect, lines) |
Bram Moolenaar | 6c89686 | 2016-11-17 19:46:51 +0100 | [diff] [blame] | 190 | call s:close_windows() |
Bram Moolenaar | 04958cb | 2018-06-23 19:23:02 +0200 | [diff] [blame] | 191 | endfunc |
Bram Moolenaar | 6c89686 | 2016-11-17 19:46:51 +0100 | [diff] [blame] | 192 | |
Bram Moolenaar | 04958cb | 2018-06-23 19:23:02 +0200 | [diff] [blame] | 193 | func Test_breakindent06_vartabs() |
| 194 | " breakindent set and shift by -1 |
Bram Moolenaar | 6d91bcb | 2020-08-12 18:50:36 +0200 | [diff] [blame] | 195 | CheckFeature vartabs |
Bram Moolenaar | 04958cb | 2018-06-23 19:23:02 +0200 | [diff] [blame] | 196 | call s:test_windows('setl briopt=shift:-1,min:0 vts=4') |
| 197 | let lines = s:screen_lines(line('.'),8) |
| 198 | let expect = [ |
| 199 | \ " abcd", |
| 200 | \ " qrstu", |
| 201 | \ " HIJKL", |
| 202 | \ ] |
| 203 | call s:compare_lines(expect, lines) |
| 204 | call s:close_windows('set vts&') |
| 205 | endfunc |
| 206 | |
| 207 | func Test_breakindent07() |
Bram Moolenaar | 6c89686 | 2016-11-17 19:46:51 +0100 | [diff] [blame] | 208 | " breakindent set and shift by 1, Number set sbr=? and briopt:sbr |
Bram Moolenaar | 544d3bc | 2017-02-05 21:14:50 +0100 | [diff] [blame] | 209 | call s:test_windows('setl briopt=shift:1,sbr,min:0 nu sbr=? nuw=4 cpo+=n') |
Bram Moolenaar | 04958cb | 2018-06-23 19:23:02 +0200 | [diff] [blame] | 210 | let lines = s:screen_lines(line('.'),10) |
| 211 | let expect = [ |
| 212 | \ " 2 ab", |
| 213 | \ "? m", |
| 214 | \ "? x", |
| 215 | \ ] |
Bram Moolenaar | 544d3bc | 2017-02-05 21:14:50 +0100 | [diff] [blame] | 216 | call s:compare_lines(expect, lines) |
Bram Moolenaar | 6c89686 | 2016-11-17 19:46:51 +0100 | [diff] [blame] | 217 | " clean up |
| 218 | call s:close_windows('set sbr= cpo-=n') |
Bram Moolenaar | 04958cb | 2018-06-23 19:23:02 +0200 | [diff] [blame] | 219 | endfunc |
Bram Moolenaar | 6c89686 | 2016-11-17 19:46:51 +0100 | [diff] [blame] | 220 | |
Bram Moolenaar | 04958cb | 2018-06-23 19:23:02 +0200 | [diff] [blame] | 221 | func Test_breakindent07_vartabs() |
Bram Moolenaar | 6d91bcb | 2020-08-12 18:50:36 +0200 | [diff] [blame] | 222 | CheckFeature vartabs |
Bram Moolenaar | 04958cb | 2018-06-23 19:23:02 +0200 | [diff] [blame] | 223 | " breakindent set and shift by 1, Number set sbr=? and briopt:sbr |
| 224 | call s:test_windows('setl briopt=shift:1,sbr,min:0 nu sbr=? nuw=4 cpo+=n vts=4') |
| 225 | let lines = s:screen_lines(line('.'),10) |
| 226 | let expect = [ |
| 227 | \ " 2 ab", |
| 228 | \ "? m", |
| 229 | \ "? x", |
| 230 | \ ] |
| 231 | call s:compare_lines(expect, lines) |
| 232 | " clean up |
| 233 | call s:close_windows('set sbr= cpo-=n vts&') |
| 234 | endfunc |
| 235 | |
| 236 | func Test_breakindent07a() |
Bram Moolenaar | 6c89686 | 2016-11-17 19:46:51 +0100 | [diff] [blame] | 237 | " breakindent set and shift by 1, Number set sbr=? and briopt:sbr |
Bram Moolenaar | 544d3bc | 2017-02-05 21:14:50 +0100 | [diff] [blame] | 238 | call s:test_windows('setl briopt=shift:1,sbr,min:0 nu sbr=? nuw=4') |
Bram Moolenaar | 04958cb | 2018-06-23 19:23:02 +0200 | [diff] [blame] | 239 | let lines = s:screen_lines(line('.'),10) |
| 240 | let expect = [ |
| 241 | \ " 2 ab", |
| 242 | \ " ? m", |
| 243 | \ " ? x", |
| 244 | \ ] |
Bram Moolenaar | 544d3bc | 2017-02-05 21:14:50 +0100 | [diff] [blame] | 245 | call s:compare_lines(expect, lines) |
Bram Moolenaar | 6c89686 | 2016-11-17 19:46:51 +0100 | [diff] [blame] | 246 | " clean up |
| 247 | call s:close_windows('set sbr=') |
Bram Moolenaar | 04958cb | 2018-06-23 19:23:02 +0200 | [diff] [blame] | 248 | endfunc |
Bram Moolenaar | 6c89686 | 2016-11-17 19:46:51 +0100 | [diff] [blame] | 249 | |
Bram Moolenaar | 04958cb | 2018-06-23 19:23:02 +0200 | [diff] [blame] | 250 | func Test_breakindent07a_vartabs() |
Bram Moolenaar | 6d91bcb | 2020-08-12 18:50:36 +0200 | [diff] [blame] | 251 | CheckFeature vartabs |
Bram Moolenaar | 04958cb | 2018-06-23 19:23:02 +0200 | [diff] [blame] | 252 | " breakindent set and shift by 1, Number set sbr=? and briopt:sbr |
| 253 | call s:test_windows('setl briopt=shift:1,sbr,min:0 nu sbr=? nuw=4 vts=4') |
| 254 | let lines = s:screen_lines(line('.'),10) |
| 255 | let expect = [ |
| 256 | \ " 2 ab", |
| 257 | \ " ? m", |
| 258 | \ " ? x", |
| 259 | \ ] |
| 260 | call s:compare_lines(expect, lines) |
| 261 | " clean up |
| 262 | call s:close_windows('set sbr= vts&') |
| 263 | endfunc |
| 264 | |
| 265 | func Test_breakindent08() |
Bram Moolenaar | 6c89686 | 2016-11-17 19:46:51 +0100 | [diff] [blame] | 266 | " breakindent set and shift by 1, Number and list set sbr=# and briopt:sbr |
Bram Moolenaar | 544d3bc | 2017-02-05 21:14:50 +0100 | [diff] [blame] | 267 | call s:test_windows('setl briopt=shift:1,sbr,min:0 nu nuw=4 sbr=# list cpo+=n ts=4') |
Bram Moolenaar | 6c89686 | 2016-11-17 19:46:51 +0100 | [diff] [blame] | 268 | " make sure, cache is invalidated! |
| 269 | set ts=8 |
| 270 | redraw! |
| 271 | set ts=4 |
| 272 | redraw! |
Bram Moolenaar | 04958cb | 2018-06-23 19:23:02 +0200 | [diff] [blame] | 273 | let lines = s:screen_lines(line('.'),10) |
| 274 | let expect = [ |
| 275 | \ " 2 ^Iabcd", |
| 276 | \ "# opq", |
| 277 | \ "# BCD", |
| 278 | \ ] |
Bram Moolenaar | 544d3bc | 2017-02-05 21:14:50 +0100 | [diff] [blame] | 279 | call s:compare_lines(expect, lines) |
Bram Moolenaar | 6c89686 | 2016-11-17 19:46:51 +0100 | [diff] [blame] | 280 | call s:close_windows('set sbr= cpo-=n') |
Bram Moolenaar | 04958cb | 2018-06-23 19:23:02 +0200 | [diff] [blame] | 281 | endfunc |
Bram Moolenaar | 6c89686 | 2016-11-17 19:46:51 +0100 | [diff] [blame] | 282 | |
Bram Moolenaar | 04958cb | 2018-06-23 19:23:02 +0200 | [diff] [blame] | 283 | func Test_breakindent08_vartabs() |
Bram Moolenaar | 6d91bcb | 2020-08-12 18:50:36 +0200 | [diff] [blame] | 284 | CheckFeature vartabs |
Bram Moolenaar | 04958cb | 2018-06-23 19:23:02 +0200 | [diff] [blame] | 285 | " breakindent set and shift by 1, Number and list set sbr=# and briopt:sbr |
| 286 | call s:test_windows('setl briopt=shift:1,sbr,min:0 nu nuw=4 sbr=# list cpo+=n ts=4 vts=4') |
| 287 | " make sure, cache is invalidated! |
| 288 | set ts=8 |
| 289 | redraw! |
| 290 | set ts=4 |
| 291 | redraw! |
| 292 | let lines = s:screen_lines(line('.'),10) |
| 293 | let expect = [ |
| 294 | \ " 2 ^Iabcd", |
| 295 | \ "# opq", |
| 296 | \ "# BCD", |
| 297 | \ ] |
| 298 | call s:compare_lines(expect, lines) |
| 299 | call s:close_windows('set sbr= cpo-=n vts&') |
| 300 | endfunc |
| 301 | |
| 302 | func Test_breakindent08a() |
Bram Moolenaar | 6c89686 | 2016-11-17 19:46:51 +0100 | [diff] [blame] | 303 | " breakindent set and shift by 1, Number and list set sbr=# and briopt:sbr |
Bram Moolenaar | 544d3bc | 2017-02-05 21:14:50 +0100 | [diff] [blame] | 304 | call s:test_windows('setl briopt=shift:1,sbr,min:0 nu nuw=4 sbr=# list') |
Bram Moolenaar | 04958cb | 2018-06-23 19:23:02 +0200 | [diff] [blame] | 305 | let lines = s:screen_lines(line('.'),10) |
| 306 | let expect = [ |
| 307 | \ " 2 ^Iabcd", |
| 308 | \ " # opq", |
| 309 | \ " # BCD", |
| 310 | \ ] |
Bram Moolenaar | 544d3bc | 2017-02-05 21:14:50 +0100 | [diff] [blame] | 311 | call s:compare_lines(expect, lines) |
Bram Moolenaar | 6c89686 | 2016-11-17 19:46:51 +0100 | [diff] [blame] | 312 | call s:close_windows('set sbr=') |
Bram Moolenaar | 04958cb | 2018-06-23 19:23:02 +0200 | [diff] [blame] | 313 | endfunc |
Bram Moolenaar | 6c89686 | 2016-11-17 19:46:51 +0100 | [diff] [blame] | 314 | |
Bram Moolenaar | 04958cb | 2018-06-23 19:23:02 +0200 | [diff] [blame] | 315 | func Test_breakindent08a_vartabs() |
Bram Moolenaar | 6d91bcb | 2020-08-12 18:50:36 +0200 | [diff] [blame] | 316 | CheckFeature vartabs |
Bram Moolenaar | 04958cb | 2018-06-23 19:23:02 +0200 | [diff] [blame] | 317 | " breakindent set and shift by 1, Number and list set sbr=# and briopt:sbr |
| 318 | call s:test_windows('setl briopt=shift:1,sbr,min:0 nu nuw=4 sbr=# list vts=4') |
| 319 | let lines = s:screen_lines(line('.'),10) |
| 320 | let expect = [ |
| 321 | \ " 2 ^Iabcd", |
| 322 | \ " # opq", |
| 323 | \ " # BCD", |
| 324 | \ ] |
| 325 | call s:compare_lines(expect, lines) |
| 326 | call s:close_windows('set sbr= vts&') |
| 327 | endfunc |
| 328 | |
| 329 | func Test_breakindent09() |
Bram Moolenaar | 6c89686 | 2016-11-17 19:46:51 +0100 | [diff] [blame] | 330 | " breakindent set and shift by 1, Number and list set sbr=# |
Bram Moolenaar | 544d3bc | 2017-02-05 21:14:50 +0100 | [diff] [blame] | 331 | call s:test_windows('setl briopt=shift:1,min:0 nu nuw=4 sbr=# list') |
Bram Moolenaar | 04958cb | 2018-06-23 19:23:02 +0200 | [diff] [blame] | 332 | let lines = s:screen_lines(line('.'),10) |
| 333 | let expect = [ |
| 334 | \ " 2 ^Iabcd", |
| 335 | \ " #op", |
| 336 | \ " #AB", |
| 337 | \ ] |
Bram Moolenaar | 544d3bc | 2017-02-05 21:14:50 +0100 | [diff] [blame] | 338 | call s:compare_lines(expect, lines) |
Bram Moolenaar | 6c89686 | 2016-11-17 19:46:51 +0100 | [diff] [blame] | 339 | call s:close_windows('set sbr=') |
Bram Moolenaar | 04958cb | 2018-06-23 19:23:02 +0200 | [diff] [blame] | 340 | endfunc |
Bram Moolenaar | 6c89686 | 2016-11-17 19:46:51 +0100 | [diff] [blame] | 341 | |
Bram Moolenaar | 04958cb | 2018-06-23 19:23:02 +0200 | [diff] [blame] | 342 | func Test_breakindent09_vartabs() |
Bram Moolenaar | 6d91bcb | 2020-08-12 18:50:36 +0200 | [diff] [blame] | 343 | CheckFeature vartabs |
Bram Moolenaar | 04958cb | 2018-06-23 19:23:02 +0200 | [diff] [blame] | 344 | " breakindent set and shift by 1, Number and list set sbr=# |
| 345 | call s:test_windows('setl briopt=shift:1,min:0 nu nuw=4 sbr=# list vts=4') |
| 346 | let lines = s:screen_lines(line('.'),10) |
| 347 | let expect = [ |
| 348 | \ " 2 ^Iabcd", |
| 349 | \ " #op", |
| 350 | \ " #AB", |
| 351 | \ ] |
| 352 | call s:compare_lines(expect, lines) |
| 353 | call s:close_windows('set sbr= vts&') |
| 354 | endfunc |
| 355 | |
| 356 | func Test_breakindent10() |
Bram Moolenaar | 6c89686 | 2016-11-17 19:46:51 +0100 | [diff] [blame] | 357 | " breakindent set, Number set sbr=~ |
Bram Moolenaar | 544d3bc | 2017-02-05 21:14:50 +0100 | [diff] [blame] | 358 | call s:test_windows('setl cpo+=n sbr=~ nu nuw=4 nolist briopt=sbr,min:0') |
Bram Moolenaar | 6c89686 | 2016-11-17 19:46:51 +0100 | [diff] [blame] | 359 | " make sure, cache is invalidated! |
| 360 | set ts=8 |
| 361 | redraw! |
| 362 | set ts=4 |
| 363 | redraw! |
Bram Moolenaar | 04958cb | 2018-06-23 19:23:02 +0200 | [diff] [blame] | 364 | let lines = s:screen_lines(line('.'),10) |
| 365 | let expect = [ |
| 366 | \ " 2 ab", |
| 367 | \ "~ mn", |
| 368 | \ "~ yz", |
| 369 | \ ] |
Bram Moolenaar | 544d3bc | 2017-02-05 21:14:50 +0100 | [diff] [blame] | 370 | call s:compare_lines(expect, lines) |
Bram Moolenaar | 6c89686 | 2016-11-17 19:46:51 +0100 | [diff] [blame] | 371 | call s:close_windows('set sbr= cpo-=n') |
Bram Moolenaar | 04958cb | 2018-06-23 19:23:02 +0200 | [diff] [blame] | 372 | endfunc |
Bram Moolenaar | 6c89686 | 2016-11-17 19:46:51 +0100 | [diff] [blame] | 373 | |
Bram Moolenaar | 04958cb | 2018-06-23 19:23:02 +0200 | [diff] [blame] | 374 | func Test_breakindent10_vartabs() |
Bram Moolenaar | 6d91bcb | 2020-08-12 18:50:36 +0200 | [diff] [blame] | 375 | CheckFeature vartabs |
Bram Moolenaar | 04958cb | 2018-06-23 19:23:02 +0200 | [diff] [blame] | 376 | " breakindent set, Number set sbr=~ |
| 377 | call s:test_windows('setl cpo+=n sbr=~ nu nuw=4 nolist briopt=sbr,min:0 vts=4') |
| 378 | " make sure, cache is invalidated! |
| 379 | set ts=8 |
| 380 | redraw! |
| 381 | set ts=4 |
| 382 | redraw! |
| 383 | let lines = s:screen_lines(line('.'),10) |
| 384 | let expect = [ |
| 385 | \ " 2 ab", |
| 386 | \ "~ mn", |
| 387 | \ "~ yz", |
| 388 | \ ] |
| 389 | call s:compare_lines(expect, lines) |
| 390 | call s:close_windows('set sbr= cpo-=n vts&') |
| 391 | endfunc |
| 392 | |
| 393 | func Test_breakindent11() |
Bram Moolenaar | 6c89686 | 2016-11-17 19:46:51 +0100 | [diff] [blame] | 394 | " test strdisplaywidth() |
Bram Moolenaar | 544d3bc | 2017-02-05 21:14:50 +0100 | [diff] [blame] | 395 | call s:test_windows('setl cpo-=n sbr=>> nu nuw=4 nolist briopt= ts=4') |
Bram Moolenaar | 04958cb | 2018-06-23 19:23:02 +0200 | [diff] [blame] | 396 | let text = getline(2) |
Bram Moolenaar | f9f24ce | 2019-08-31 21:17:39 +0200 | [diff] [blame] | 397 | let width = strlen(text[1:]) + indent(2) + strlen(&sbr) * 3 " text wraps 3 times |
Bram Moolenaar | 6c89686 | 2016-11-17 19:46:51 +0100 | [diff] [blame] | 398 | call assert_equal(width, strdisplaywidth(text)) |
| 399 | call s:close_windows('set sbr=') |
Bram Moolenaar | 0e05de4 | 2020-03-25 22:23:46 +0100 | [diff] [blame] | 400 | call assert_equal(4, strdisplaywidth("\t", 4)) |
Bram Moolenaar | 04958cb | 2018-06-23 19:23:02 +0200 | [diff] [blame] | 401 | endfunc |
Bram Moolenaar | 6c89686 | 2016-11-17 19:46:51 +0100 | [diff] [blame] | 402 | |
Bram Moolenaar | 04958cb | 2018-06-23 19:23:02 +0200 | [diff] [blame] | 403 | func Test_breakindent11_vartabs() |
Bram Moolenaar | 6d91bcb | 2020-08-12 18:50:36 +0200 | [diff] [blame] | 404 | CheckFeature vartabs |
Bram Moolenaar | 04958cb | 2018-06-23 19:23:02 +0200 | [diff] [blame] | 405 | " test strdisplaywidth() |
| 406 | call s:test_windows('setl cpo-=n sbr=>> nu nuw=4 nolist briopt= ts=4 vts=4') |
| 407 | let text = getline(2) |
Bram Moolenaar | f9f24ce | 2019-08-31 21:17:39 +0200 | [diff] [blame] | 408 | let width = strlen(text[1:]) + 2->indent() + strlen(&sbr) * 3 " text wraps 3 times |
Bram Moolenaar | f6ed61e | 2019-09-07 19:05:09 +0200 | [diff] [blame] | 409 | call assert_equal(width, text->strdisplaywidth()) |
Bram Moolenaar | 04958cb | 2018-06-23 19:23:02 +0200 | [diff] [blame] | 410 | call s:close_windows('set sbr= vts&') |
| 411 | endfunc |
| 412 | |
| 413 | func Test_breakindent12() |
Bram Moolenaar | 6c89686 | 2016-11-17 19:46:51 +0100 | [diff] [blame] | 414 | " test breakindent with long indent |
Bram Moolenaar | 04958cb | 2018-06-23 19:23:02 +0200 | [diff] [blame] | 415 | let s:input = "\t\t\t\t\t{" |
Bram Moolenaar | 544d3bc | 2017-02-05 21:14:50 +0100 | [diff] [blame] | 416 | call s:test_windows('setl breakindent linebreak briopt=min:10 nu numberwidth=3 ts=4 list listchars=tab:>-') |
Bram Moolenaar | 04958cb | 2018-06-23 19:23:02 +0200 | [diff] [blame] | 417 | let lines = s:screen_lines(2,16) |
| 418 | let expect = [ |
| 419 | \ " 2 >--->--->--->", |
| 420 | \ " ---{ ", |
| 421 | \ "~ ", |
| 422 | \ ] |
Bram Moolenaar | 544d3bc | 2017-02-05 21:14:50 +0100 | [diff] [blame] | 423 | call s:compare_lines(expect, lines) |
Bram Moolenaar | 6c89686 | 2016-11-17 19:46:51 +0100 | [diff] [blame] | 424 | call s:close_windows('set nuw=4 listchars=') |
Bram Moolenaar | 04958cb | 2018-06-23 19:23:02 +0200 | [diff] [blame] | 425 | endfunc |
Bram Moolenaar | 6c89686 | 2016-11-17 19:46:51 +0100 | [diff] [blame] | 426 | |
Bram Moolenaar | 04958cb | 2018-06-23 19:23:02 +0200 | [diff] [blame] | 427 | func Test_breakindent12_vartabs() |
Bram Moolenaar | 6d91bcb | 2020-08-12 18:50:36 +0200 | [diff] [blame] | 428 | CheckFeature vartabs |
Bram Moolenaar | 04958cb | 2018-06-23 19:23:02 +0200 | [diff] [blame] | 429 | " test breakindent with long indent |
| 430 | let s:input = "\t\t\t\t\t{" |
| 431 | call s:test_windows('setl breakindent linebreak briopt=min:10 nu numberwidth=3 ts=4 list listchars=tab:>- vts=4') |
| 432 | let lines = s:screen_lines(2,16) |
| 433 | let expect = [ |
| 434 | \ " 2 >--->--->--->", |
| 435 | \ " ---{ ", |
| 436 | \ "~ ", |
| 437 | \ ] |
| 438 | call s:compare_lines(expect, lines) |
| 439 | call s:close_windows('set nuw=4 listchars= vts&') |
| 440 | endfunc |
| 441 | |
| 442 | func Test_breakindent13() |
| 443 | let s:input = "" |
Bram Moolenaar | 544d3bc | 2017-02-05 21:14:50 +0100 | [diff] [blame] | 444 | call s:test_windows('setl breakindent briopt=min:10 ts=8') |
Bram Moolenaar | 6c89686 | 2016-11-17 19:46:51 +0100 | [diff] [blame] | 445 | vert resize 20 |
| 446 | call setline(1, [" a\tb\tc\td\te", " z y x w v"]) |
| 447 | 1 |
| 448 | norm! fbgj"ayl |
| 449 | 2 |
| 450 | norm! fygj"byl |
| 451 | call assert_equal('d', @a) |
| 452 | call assert_equal('w', @b) |
| 453 | call s:close_windows() |
Bram Moolenaar | 04958cb | 2018-06-23 19:23:02 +0200 | [diff] [blame] | 454 | endfunc |
Bram Moolenaar | 6c89686 | 2016-11-17 19:46:51 +0100 | [diff] [blame] | 455 | |
Bram Moolenaar | 04958cb | 2018-06-23 19:23:02 +0200 | [diff] [blame] | 456 | func Test_breakindent13_vartabs() |
Bram Moolenaar | 6d91bcb | 2020-08-12 18:50:36 +0200 | [diff] [blame] | 457 | CheckFeature vartabs |
Bram Moolenaar | 04958cb | 2018-06-23 19:23:02 +0200 | [diff] [blame] | 458 | let s:input = "" |
| 459 | call s:test_windows('setl breakindent briopt=min:10 ts=8 vts=8') |
| 460 | vert resize 20 |
| 461 | call setline(1, [" a\tb\tc\td\te", " z y x w v"]) |
| 462 | 1 |
| 463 | norm! fbgj"ayl |
| 464 | 2 |
| 465 | norm! fygj"byl |
| 466 | call assert_equal('d', @a) |
| 467 | call assert_equal('w', @b) |
| 468 | call s:close_windows('set vts&') |
| 469 | endfunc |
| 470 | |
| 471 | func Test_breakindent14() |
| 472 | let s:input = "" |
Bram Moolenaar | 544d3bc | 2017-02-05 21:14:50 +0100 | [diff] [blame] | 473 | call s:test_windows('setl breakindent briopt= ts=8') |
Bram Moolenaar | 6c89686 | 2016-11-17 19:46:51 +0100 | [diff] [blame] | 474 | vert resize 30 |
| 475 | norm! 3a1234567890 |
| 476 | norm! a abcde |
| 477 | exec "norm! 0\<C-V>tex" |
Bram Moolenaar | 04958cb | 2018-06-23 19:23:02 +0200 | [diff] [blame] | 478 | let lines = s:screen_lines(line('.'),8) |
| 479 | let expect = [ |
| 480 | \ "e ", |
| 481 | \ "~ ", |
| 482 | \ "~ ", |
| 483 | \ ] |
Bram Moolenaar | 544d3bc | 2017-02-05 21:14:50 +0100 | [diff] [blame] | 484 | call s:compare_lines(expect, lines) |
Bram Moolenaar | 6c89686 | 2016-11-17 19:46:51 +0100 | [diff] [blame] | 485 | call s:close_windows() |
Bram Moolenaar | 04958cb | 2018-06-23 19:23:02 +0200 | [diff] [blame] | 486 | endfunc |
Bram Moolenaar | 6c89686 | 2016-11-17 19:46:51 +0100 | [diff] [blame] | 487 | |
Bram Moolenaar | 04958cb | 2018-06-23 19:23:02 +0200 | [diff] [blame] | 488 | func Test_breakindent14_vartabs() |
Bram Moolenaar | 6d91bcb | 2020-08-12 18:50:36 +0200 | [diff] [blame] | 489 | CheckFeature vartabs |
Bram Moolenaar | 04958cb | 2018-06-23 19:23:02 +0200 | [diff] [blame] | 490 | let s:input = "" |
| 491 | call s:test_windows('setl breakindent briopt= ts=8 vts=8') |
| 492 | vert resize 30 |
| 493 | norm! 3a1234567890 |
| 494 | norm! a abcde |
| 495 | exec "norm! 0\<C-V>tex" |
| 496 | let lines = s:screen_lines(line('.'),8) |
| 497 | let expect = [ |
| 498 | \ "e ", |
| 499 | \ "~ ", |
| 500 | \ "~ ", |
| 501 | \ ] |
| 502 | call s:compare_lines(expect, lines) |
| 503 | call s:close_windows('set vts&') |
| 504 | endfunc |
| 505 | |
| 506 | func Test_breakindent15() |
| 507 | let s:input = "" |
Bram Moolenaar | 544d3bc | 2017-02-05 21:14:50 +0100 | [diff] [blame] | 508 | call s:test_windows('setl breakindent briopt= ts=8 sw=8') |
Bram Moolenaar | 6c89686 | 2016-11-17 19:46:51 +0100 | [diff] [blame] | 509 | vert resize 30 |
| 510 | norm! 4a1234567890 |
| 511 | exe "normal! >>\<C-V>3f0x" |
Bram Moolenaar | 04958cb | 2018-06-23 19:23:02 +0200 | [diff] [blame] | 512 | let lines = s:screen_lines(line('.'),20) |
| 513 | let expect = [ |
| 514 | \ " 1234567890 ", |
| 515 | \ "~ ", |
| 516 | \ "~ ", |
| 517 | \ ] |
Bram Moolenaar | 544d3bc | 2017-02-05 21:14:50 +0100 | [diff] [blame] | 518 | call s:compare_lines(expect, lines) |
Bram Moolenaar | 6c89686 | 2016-11-17 19:46:51 +0100 | [diff] [blame] | 519 | call s:close_windows() |
Bram Moolenaar | 04958cb | 2018-06-23 19:23:02 +0200 | [diff] [blame] | 520 | endfunc |
Bram Moolenaar | 6c89686 | 2016-11-17 19:46:51 +0100 | [diff] [blame] | 521 | |
Bram Moolenaar | 04958cb | 2018-06-23 19:23:02 +0200 | [diff] [blame] | 522 | func Test_breakindent15_vartabs() |
Bram Moolenaar | 6d91bcb | 2020-08-12 18:50:36 +0200 | [diff] [blame] | 523 | CheckFeature vartabs |
Bram Moolenaar | 04958cb | 2018-06-23 19:23:02 +0200 | [diff] [blame] | 524 | let s:input = "" |
| 525 | call s:test_windows('setl breakindent briopt= ts=8 sw=8 vts=8') |
| 526 | vert resize 30 |
| 527 | norm! 4a1234567890 |
| 528 | exe "normal! >>\<C-V>3f0x" |
| 529 | let lines = s:screen_lines(line('.'),20) |
| 530 | let expect = [ |
| 531 | \ " 1234567890 ", |
| 532 | \ "~ ", |
| 533 | \ "~ ", |
| 534 | \ ] |
| 535 | call s:compare_lines(expect, lines) |
| 536 | call s:close_windows('set vts&') |
| 537 | endfunc |
| 538 | |
| 539 | func Test_breakindent16() |
Bram Moolenaar | 6c89686 | 2016-11-17 19:46:51 +0100 | [diff] [blame] | 540 | " Check that overlong lines are indented correctly. |
Bram Moolenaar | 04958cb | 2018-06-23 19:23:02 +0200 | [diff] [blame] | 541 | let s:input = "" |
Bram Moolenaar | 544d3bc | 2017-02-05 21:14:50 +0100 | [diff] [blame] | 542 | call s:test_windows('setl breakindent briopt=min:0 ts=4') |
Bram Moolenaar | 6c89686 | 2016-11-17 19:46:51 +0100 | [diff] [blame] | 543 | call setline(1, "\t".repeat("1234567890", 10)) |
| 544 | resize 6 |
| 545 | norm! 1gg$ |
| 546 | redraw! |
Bram Moolenaar | 04958cb | 2018-06-23 19:23:02 +0200 | [diff] [blame] | 547 | let lines = s:screen_lines(1,10) |
| 548 | let expect = [ |
| 549 | \ " 789012", |
| 550 | \ " 345678", |
| 551 | \ " 901234", |
| 552 | \ ] |
Bram Moolenaar | 544d3bc | 2017-02-05 21:14:50 +0100 | [diff] [blame] | 553 | call s:compare_lines(expect, lines) |
Bram Moolenaar | 04958cb | 2018-06-23 19:23:02 +0200 | [diff] [blame] | 554 | let lines = s:screen_lines(4,10) |
| 555 | let expect = [ |
| 556 | \ " 567890", |
| 557 | \ " 123456", |
| 558 | \ " 7890 ", |
| 559 | \ ] |
Bram Moolenaar | 544d3bc | 2017-02-05 21:14:50 +0100 | [diff] [blame] | 560 | call s:compare_lines(expect, lines) |
Bram Moolenaar | 6c89686 | 2016-11-17 19:46:51 +0100 | [diff] [blame] | 561 | call s:close_windows() |
Bram Moolenaar | 04958cb | 2018-06-23 19:23:02 +0200 | [diff] [blame] | 562 | endfunc |
| 563 | |
| 564 | func Test_breakindent16_vartabs() |
Bram Moolenaar | 6d91bcb | 2020-08-12 18:50:36 +0200 | [diff] [blame] | 565 | CheckFeature vartabs |
Bram Moolenaar | 04958cb | 2018-06-23 19:23:02 +0200 | [diff] [blame] | 566 | " Check that overlong lines are indented correctly. |
| 567 | let s:input = "" |
| 568 | call s:test_windows('setl breakindent briopt=min:0 ts=4 vts=4') |
| 569 | call setline(1, "\t".repeat("1234567890", 10)) |
| 570 | resize 6 |
| 571 | norm! 1gg$ |
| 572 | redraw! |
| 573 | let lines = s:screen_lines(1,10) |
| 574 | let expect = [ |
| 575 | \ " 789012", |
| 576 | \ " 345678", |
| 577 | \ " 901234", |
| 578 | \ ] |
| 579 | call s:compare_lines(expect, lines) |
| 580 | let lines = s:screen_lines(4,10) |
| 581 | let expect = [ |
| 582 | \ " 567890", |
| 583 | \ " 123456", |
| 584 | \ " 7890 ", |
| 585 | \ ] |
| 586 | call s:compare_lines(expect, lines) |
| 587 | call s:close_windows('set vts&') |
| 588 | endfunc |
Bram Moolenaar | 2f7b7b1 | 2019-11-03 15:46:48 +0100 | [diff] [blame] | 589 | |
| 590 | func Test_breakindent17_vartabs() |
Bram Moolenaar | 6d91bcb | 2020-08-12 18:50:36 +0200 | [diff] [blame] | 591 | CheckFeature vartabs |
Bram Moolenaar | 2f7b7b1 | 2019-11-03 15:46:48 +0100 | [diff] [blame] | 592 | let s:input = "" |
| 593 | call s:test_windows('setl breakindent list listchars=tab:<-> showbreak=+++') |
| 594 | call setline(1, "\t" . repeat('a', 63)) |
| 595 | vert resize 30 |
| 596 | norm! 1gg$ |
| 597 | redraw! |
| 598 | let lines = s:screen_lines(1, 30) |
| 599 | let expect = [ |
| 600 | \ "<-->aaaaaaaaaaaaaaaaaaaaaaaaaa", |
| 601 | \ " +++aaaaaaaaaaaaaaaaaaaaaaa", |
| 602 | \ " +++aaaaaaaaaaaaaa ", |
| 603 | \ ] |
| 604 | call s:compare_lines(expect, lines) |
| 605 | call s:close_windows('set breakindent& list& listchars& showbreak&') |
| 606 | endfunc |
| 607 | |
| 608 | func Test_breakindent18_vartabs() |
Bram Moolenaar | 6d91bcb | 2020-08-12 18:50:36 +0200 | [diff] [blame] | 609 | CheckFeature vartabs |
Bram Moolenaar | 2f7b7b1 | 2019-11-03 15:46:48 +0100 | [diff] [blame] | 610 | let s:input = "" |
| 611 | call s:test_windows('setl breakindent list listchars=tab:<->') |
| 612 | call setline(1, "\t" . repeat('a', 63)) |
| 613 | vert resize 30 |
| 614 | norm! 1gg$ |
| 615 | redraw! |
| 616 | let lines = s:screen_lines(1, 30) |
| 617 | let expect = [ |
| 618 | \ "<-->aaaaaaaaaaaaaaaaaaaaaaaaaa", |
| 619 | \ " aaaaaaaaaaaaaaaaaaaaaaaaaa", |
| 620 | \ " aaaaaaaaaaa ", |
| 621 | \ ] |
| 622 | call s:compare_lines(expect, lines) |
| 623 | call s:close_windows('set breakindent& list& listchars&') |
| 624 | endfunc |
| 625 | |
Bram Moolenaar | dfede9a | 2020-01-23 19:59:22 +0100 | [diff] [blame] | 626 | func Test_breakindent19_sbr_nextpage() |
| 627 | let s:input = "" |
| 628 | call s:test_windows('setl breakindent briopt=shift:2,sbr,min:18 sbr=>') |
| 629 | call setline(1, repeat('a', 200)) |
| 630 | norm! 1gg |
| 631 | redraw! |
| 632 | let lines = s:screen_lines(1, 20) |
| 633 | let expect = [ |
| 634 | \ "aaaaaaaaaaaaaaaaaaaa", |
| 635 | \ "> aaaaaaaaaaaaaaaaaa", |
| 636 | \ "> aaaaaaaaaaaaaaaaaa", |
| 637 | \ ] |
| 638 | call s:compare_lines(expect, lines) |
| 639 | " Scroll down one screen line |
| 640 | setl scrolloff=5 |
Bram Moolenaar | 5202929 | 2021-02-10 21:20:30 +0100 | [diff] [blame] | 641 | norm! 5gj |
Bram Moolenaar | dfede9a | 2020-01-23 19:59:22 +0100 | [diff] [blame] | 642 | let lines = s:screen_lines(1, 20) |
| 643 | let expect = [ |
Bram Moolenaar | 5202929 | 2021-02-10 21:20:30 +0100 | [diff] [blame] | 644 | \ "aaaaaaaaaaaaaaaaaaaa", |
Bram Moolenaar | dfede9a | 2020-01-23 19:59:22 +0100 | [diff] [blame] | 645 | \ "> aaaaaaaaaaaaaaaaaa", |
| 646 | \ "> aaaaaaaaaaaaaaaaaa", |
| 647 | \ ] |
| 648 | call s:compare_lines(expect, lines) |
Bram Moolenaar | 5202929 | 2021-02-10 21:20:30 +0100 | [diff] [blame] | 649 | redraw! |
| 650 | " moving the cursor doesn't change the text offset |
| 651 | norm! l |
| 652 | redraw! |
| 653 | let lines = s:screen_lines(1, 20) |
| 654 | call s:compare_lines(expect, lines) |
Bram Moolenaar | 1aa76b8 | 2020-02-23 15:17:27 +0100 | [diff] [blame] | 655 | |
| 656 | setl breakindent briopt=min:18 sbr=> |
| 657 | norm! 5gj |
| 658 | let lines = s:screen_lines(1, 20) |
| 659 | let expect = [ |
| 660 | \ ">aaaaaaaaaaaaaaaaaaa", |
| 661 | \ ">aaaaaaaaaaaaaaaaaaa", |
| 662 | \ ">aaaaaaaaaaaaaaaaaaa", |
| 663 | \ ] |
| 664 | call s:compare_lines(expect, lines) |
Bram Moolenaar | dfede9a | 2020-01-23 19:59:22 +0100 | [diff] [blame] | 665 | call s:close_windows('set breakindent& briopt& sbr&') |
| 666 | endfunc |
Bram Moolenaar | 0e05de4 | 2020-03-25 22:23:46 +0100 | [diff] [blame] | 667 | |
Bram Moolenaar | e882f7a | 2020-05-16 14:07:39 +0200 | [diff] [blame] | 668 | func Test_breakindent20_cpo_n_nextpage() |
| 669 | let s:input = "" |
| 670 | call s:test_windows('setl breakindent briopt=min:14 cpo+=n number') |
| 671 | call setline(1, repeat('a', 200)) |
| 672 | norm! 1gg |
| 673 | redraw! |
| 674 | let lines = s:screen_lines(1, 20) |
| 675 | let expect = [ |
| 676 | \ " 1 aaaaaaaaaaaaaaaa", |
| 677 | \ " aaaaaaaaaaaaaaaa", |
| 678 | \ " aaaaaaaaaaaaaaaa", |
| 679 | \ ] |
| 680 | call s:compare_lines(expect, lines) |
| 681 | " Scroll down one screen line |
| 682 | setl scrolloff=5 |
| 683 | norm! 5gj |
| 684 | redraw! |
| 685 | let lines = s:screen_lines(1, 20) |
| 686 | let expect = [ |
| 687 | \ "--1 aaaaaaaaaaaaaaaa", |
| 688 | \ " aaaaaaaaaaaaaaaa", |
| 689 | \ " aaaaaaaaaaaaaaaa", |
| 690 | \ ] |
| 691 | call s:compare_lines(expect, lines) |
| 692 | |
| 693 | setl briopt+=shift:2 |
| 694 | norm! 1gg |
| 695 | let lines = s:screen_lines(1, 20) |
| 696 | let expect = [ |
| 697 | \ " 1 aaaaaaaaaaaaaaaa", |
| 698 | \ " aaaaaaaaaaaaaa", |
| 699 | \ " aaaaaaaaaaaaaa", |
| 700 | \ ] |
| 701 | call s:compare_lines(expect, lines) |
| 702 | " Scroll down one screen line |
| 703 | norm! 5gj |
| 704 | let lines = s:screen_lines(1, 20) |
| 705 | let expect = [ |
| 706 | \ "--1 aaaaaaaaaaaaaa", |
| 707 | \ " aaaaaaaaaaaaaa", |
| 708 | \ " aaaaaaaaaaaaaa", |
| 709 | \ ] |
| 710 | call s:compare_lines(expect, lines) |
| 711 | |
| 712 | call s:close_windows('set breakindent& briopt& cpo& number&') |
| 713 | endfunc |
| 714 | |
Christian Brabandt | 4a0b85a | 2021-07-14 20:00:27 +0200 | [diff] [blame] | 715 | func Test_breakindent20_list() |
| 716 | call s:test_windows('setl breakindent breakindentopt= linebreak') |
| 717 | " default: |
| 718 | call setline(1, [' 1. Congress shall make no law', |
| 719 | \ ' 2.) Congress shall make no law', |
| 720 | \ ' 3.] Congress shall make no law']) |
| 721 | norm! 1gg |
| 722 | redraw! |
| 723 | let lines = s:screen_lines2(1, 6, 20) |
| 724 | let expect = [ |
| 725 | \ " 1. Congress ", |
| 726 | \ "shall make no law ", |
| 727 | \ " 2.) Congress ", |
| 728 | \ "shall make no law ", |
| 729 | \ " 3.] Congress ", |
| 730 | \ "shall make no law ", |
| 731 | \ ] |
| 732 | call s:compare_lines(expect, lines) |
| 733 | " set mininum indent |
| 734 | setl briopt=min:5 |
| 735 | redraw! |
| 736 | let lines = s:screen_lines2(1, 6, 20) |
| 737 | let expect = [ |
| 738 | \ " 1. Congress ", |
| 739 | \ " shall make no law ", |
| 740 | \ " 2.) Congress ", |
| 741 | \ " shall make no law ", |
| 742 | \ " 3.] Congress ", |
| 743 | \ " shall make no law ", |
| 744 | \ ] |
| 745 | call s:compare_lines(expect, lines) |
| 746 | " set additional handing indent |
| 747 | setl briopt+=list:4 |
| 748 | redraw! |
| 749 | let expect = [ |
| 750 | \ " 1. Congress ", |
| 751 | \ " shall make no ", |
| 752 | \ " law ", |
| 753 | \ " 2.) Congress ", |
| 754 | \ " shall make no ", |
| 755 | \ " law ", |
| 756 | \ " 3.] Congress ", |
| 757 | \ " shall make no ", |
| 758 | \ " law ", |
| 759 | \ ] |
| 760 | let lines = s:screen_lines2(1, 9, 20) |
| 761 | call s:compare_lines(expect, lines) |
Maxim Kim | f674b35 | 2021-07-22 11:46:59 +0200 | [diff] [blame] | 762 | |
Christian Brabandt | 4a0b85a | 2021-07-14 20:00:27 +0200 | [diff] [blame] | 763 | " reset linebreak option |
| 764 | " Note: it indents by one additional |
| 765 | " space, because of the leading space. |
| 766 | setl linebreak&vim list listchars=eol:$,space:_ |
| 767 | redraw! |
| 768 | let expect = [ |
| 769 | \ "__1.__Congress_shall", |
| 770 | \ " _make_no_law$ ", |
| 771 | \ "__2.)_Congress_shall", |
| 772 | \ " _make_no_law$ ", |
| 773 | \ "__3.]_Congress_shall", |
| 774 | \ " _make_no_law$ ", |
| 775 | \ ] |
| 776 | let lines = s:screen_lines2(1, 6, 20) |
| 777 | call s:compare_lines(expect, lines) |
| 778 | |
Maxim Kim | f674b35 | 2021-07-22 11:46:59 +0200 | [diff] [blame] | 779 | " check formatlistpat indent |
| 780 | setl briopt=min:5,list:-1 |
| 781 | setl linebreak list&vim listchars&vim |
| 782 | let &l:flp = '^\s*\d\+\.\?[\]:)}\t ]\s*' |
| 783 | redraw! |
| 784 | let expect = [ |
| 785 | \ " 1. Congress ", |
| 786 | \ " shall make no ", |
| 787 | \ " law ", |
| 788 | \ " 2.) Congress ", |
| 789 | \ " shall make no ", |
| 790 | \ " law ", |
| 791 | \ " 3.] Congress ", |
| 792 | \ " shall make no ", |
| 793 | \ " law ", |
| 794 | \ ] |
| 795 | let lines = s:screen_lines2(1, 9, 20) |
| 796 | call s:compare_lines(expect, lines) |
| 797 | " check formatlistpat indent with different list levels |
| 798 | let &l:flp = '^\s*\*\+\s\+' |
| 799 | redraw! |
| 800 | %delete _ |
| 801 | call setline(1, ['* Congress shall make no law', |
| 802 | \ '*** Congress shall make no law', |
| 803 | \ '**** Congress shall make no law']) |
| 804 | norm! 1gg |
| 805 | let expect = [ |
| 806 | \ "* Congress shall ", |
| 807 | \ " make no law ", |
| 808 | \ "*** Congress shall ", |
| 809 | \ " make no law ", |
| 810 | \ "**** Congress shall ", |
| 811 | \ " make no law ", |
| 812 | \ ] |
| 813 | let lines = s:screen_lines2(1, 6, 20) |
| 814 | call s:compare_lines(expect, lines) |
| 815 | |
| 816 | " check formatlistpat indent with different list level |
| 817 | " showbreak and sbr |
| 818 | setl briopt=min:5,sbr,list:-1,shift:2 |
| 819 | setl showbreak=> |
| 820 | redraw! |
| 821 | let expect = [ |
| 822 | \ "* Congress shall ", |
| 823 | \ "> make no law ", |
| 824 | \ "*** Congress shall ", |
| 825 | \ "> make no law ", |
| 826 | \ "**** Congress shall ", |
| 827 | \ "> make no law ", |
| 828 | \ ] |
| 829 | let lines = s:screen_lines2(1, 6, 20) |
| 830 | call s:compare_lines(expect, lines) |
| 831 | call s:close_windows('set breakindent& briopt& linebreak& list& listchars& showbreak&') |
Christian Brabandt | 4a0b85a | 2021-07-14 20:00:27 +0200 | [diff] [blame] | 832 | endfunc |
| 833 | |
Bram Moolenaar | 0e05de4 | 2020-03-25 22:23:46 +0100 | [diff] [blame] | 834 | " vim: shiftwidth=2 sts=2 expandtab |