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 |
| 4 | " while the test is run, the breakindent cacheing 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 | |
Bram Moolenaar | 04958cb | 2018-06-23 19:23:02 +0200 | [diff] [blame] | 18 | func s:compare_lines(expect, actual) |
Bram Moolenaar | 544d3bc | 2017-02-05 21:14:50 +0100 | [diff] [blame] | 19 | call assert_equal(join(a:expect, "\n"), join(a:actual, "\n")) |
Bram Moolenaar | 04958cb | 2018-06-23 19:23:02 +0200 | [diff] [blame] | 20 | endfunc |
Bram Moolenaar | 544d3bc | 2017-02-05 21:14:50 +0100 | [diff] [blame] | 21 | |
Bram Moolenaar | 04958cb | 2018-06-23 19:23:02 +0200 | [diff] [blame] | 22 | func s:test_windows(...) |
Bram Moolenaar | 544d3bc | 2017-02-05 21:14:50 +0100 | [diff] [blame] | 23 | call NewWindow(10, 20) |
| 24 | setl ts=4 sw=4 sts=4 breakindent |
Bram Moolenaar | 6c89686 | 2016-11-17 19:46:51 +0100 | [diff] [blame] | 25 | put =s:input |
Bram Moolenaar | 544d3bc | 2017-02-05 21:14:50 +0100 | [diff] [blame] | 26 | exe get(a:000, 0, '') |
Bram Moolenaar | 04958cb | 2018-06-23 19:23:02 +0200 | [diff] [blame] | 27 | endfunc |
Bram Moolenaar | 6c89686 | 2016-11-17 19:46:51 +0100 | [diff] [blame] | 28 | |
Bram Moolenaar | 04958cb | 2018-06-23 19:23:02 +0200 | [diff] [blame] | 29 | func s:close_windows(...) |
Bram Moolenaar | 544d3bc | 2017-02-05 21:14:50 +0100 | [diff] [blame] | 30 | call CloseWindow() |
| 31 | exe get(a:000, 0, '') |
Bram Moolenaar | 04958cb | 2018-06-23 19:23:02 +0200 | [diff] [blame] | 32 | endfunc |
Bram Moolenaar | 6c89686 | 2016-11-17 19:46:51 +0100 | [diff] [blame] | 33 | |
Bram Moolenaar | 04958cb | 2018-06-23 19:23:02 +0200 | [diff] [blame] | 34 | func Test_breakindent01() |
Bram Moolenaar | 6c89686 | 2016-11-17 19:46:51 +0100 | [diff] [blame] | 35 | " simple breakindent test |
Bram Moolenaar | 544d3bc | 2017-02-05 21:14:50 +0100 | [diff] [blame] | 36 | call s:test_windows('setl briopt=min:0') |
Bram Moolenaar | 04958cb | 2018-06-23 19:23:02 +0200 | [diff] [blame] | 37 | let lines = s:screen_lines(line('.'),8) |
| 38 | let expect = [ |
| 39 | \ " abcd", |
| 40 | \ " qrst", |
| 41 | \ " GHIJ", |
| 42 | \ ] |
Bram Moolenaar | 544d3bc | 2017-02-05 21:14:50 +0100 | [diff] [blame] | 43 | call s:compare_lines(expect, lines) |
Bram Moolenaar | 6c89686 | 2016-11-17 19:46:51 +0100 | [diff] [blame] | 44 | call s:close_windows() |
Bram Moolenaar | 04958cb | 2018-06-23 19:23:02 +0200 | [diff] [blame] | 45 | endfunc |
Bram Moolenaar | 6c89686 | 2016-11-17 19:46:51 +0100 | [diff] [blame] | 46 | |
Bram Moolenaar | 04958cb | 2018-06-23 19:23:02 +0200 | [diff] [blame] | 47 | func Test_breakindent01_vartabs() |
| 48 | " like 01 but with vartabs feature |
| 49 | if !has("vartabs") |
| 50 | return |
| 51 | endif |
| 52 | call s:test_windows('setl briopt=min:0 vts=4') |
| 53 | let lines = s:screen_lines(line('.'),8) |
| 54 | let expect = [ |
| 55 | \ " abcd", |
| 56 | \ " qrst", |
| 57 | \ " GHIJ", |
| 58 | \ ] |
| 59 | call s:compare_lines(expect, lines) |
| 60 | call s:close_windows('set vts&') |
| 61 | endfunc |
| 62 | |
| 63 | func Test_breakindent02() |
Bram Moolenaar | 6c89686 | 2016-11-17 19:46:51 +0100 | [diff] [blame] | 64 | " simple breakindent test with showbreak set |
Bram Moolenaar | 544d3bc | 2017-02-05 21:14:50 +0100 | [diff] [blame] | 65 | call s:test_windows('setl briopt=min:0 sbr=>>') |
Bram Moolenaar | 04958cb | 2018-06-23 19:23:02 +0200 | [diff] [blame] | 66 | let lines = s:screen_lines(line('.'),8) |
| 67 | let expect = [ |
| 68 | \ " abcd", |
| 69 | \ " >>qr", |
| 70 | \ " >>EF", |
| 71 | \ ] |
Bram Moolenaar | 544d3bc | 2017-02-05 21:14:50 +0100 | [diff] [blame] | 72 | call s:compare_lines(expect, lines) |
Bram Moolenaar | 6c89686 | 2016-11-17 19:46:51 +0100 | [diff] [blame] | 73 | call s:close_windows('set sbr=') |
Bram Moolenaar | 04958cb | 2018-06-23 19:23:02 +0200 | [diff] [blame] | 74 | endfunc |
Bram Moolenaar | 6c89686 | 2016-11-17 19:46:51 +0100 | [diff] [blame] | 75 | |
Bram Moolenaar | 04958cb | 2018-06-23 19:23:02 +0200 | [diff] [blame] | 76 | func Test_breakindent02_vartabs() |
| 77 | if !has("vartabs") |
| 78 | return |
| 79 | endif |
| 80 | " simple breakindent test with showbreak set |
| 81 | call s:test_windows('setl briopt=min:0 sbr=>> vts=4') |
| 82 | let lines = s:screen_lines(line('.'),8) |
| 83 | let expect = [ |
| 84 | \ " abcd", |
| 85 | \ " >>qr", |
| 86 | \ " >>EF", |
| 87 | \ ] |
| 88 | call s:compare_lines(expect, lines) |
| 89 | call s:close_windows('set sbr= vts&') |
| 90 | endfunc |
| 91 | |
| 92 | func Test_breakindent03() |
Bram Moolenaar | 6c89686 | 2016-11-17 19:46:51 +0100 | [diff] [blame] | 93 | " simple breakindent test with showbreak set and briopt including sbr |
Bram Moolenaar | 544d3bc | 2017-02-05 21:14:50 +0100 | [diff] [blame] | 94 | call s:test_windows('setl briopt=sbr,min:0 sbr=++') |
Bram Moolenaar | 04958cb | 2018-06-23 19:23:02 +0200 | [diff] [blame] | 95 | let lines = s:screen_lines(line('.'),8) |
| 96 | let expect = [ |
| 97 | \ " abcd", |
| 98 | \ "++ qrst", |
| 99 | \ "++ GHIJ", |
| 100 | \ ] |
Bram Moolenaar | 544d3bc | 2017-02-05 21:14:50 +0100 | [diff] [blame] | 101 | call s:compare_lines(expect, lines) |
Bram Moolenaar | 6c89686 | 2016-11-17 19:46:51 +0100 | [diff] [blame] | 102 | " clean up |
| 103 | call s:close_windows('set sbr=') |
Bram Moolenaar | 04958cb | 2018-06-23 19:23:02 +0200 | [diff] [blame] | 104 | endfunc |
Bram Moolenaar | 6c89686 | 2016-11-17 19:46:51 +0100 | [diff] [blame] | 105 | |
Bram Moolenaar | 04958cb | 2018-06-23 19:23:02 +0200 | [diff] [blame] | 106 | func Test_breakindent03_vartabs() |
| 107 | " simple breakindent test with showbreak set and briopt including sbr |
| 108 | if !has("vartabs") |
| 109 | return |
| 110 | endif |
| 111 | call s:test_windows('setl briopt=sbr,min:0 sbr=++ vts=4') |
| 112 | let lines = s:screen_lines(line('.'),8) |
| 113 | let expect = [ |
| 114 | \ " abcd", |
| 115 | \ "++ qrst", |
| 116 | \ "++ GHIJ", |
| 117 | \ ] |
| 118 | call s:compare_lines(expect, lines) |
| 119 | " clean up |
| 120 | call s:close_windows('set sbr= vts&') |
| 121 | endfunc |
| 122 | |
| 123 | func Test_breakindent04() |
Bram Moolenaar | 6c89686 | 2016-11-17 19:46:51 +0100 | [diff] [blame] | 124 | " breakindent set with min width 18 |
Bram Moolenaar | 544d3bc | 2017-02-05 21:14:50 +0100 | [diff] [blame] | 125 | call s:test_windows('setl sbr= 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 | 04958cb | 2018-06-23 19:23:02 +0200 | [diff] [blame] | 135 | endfunc |
Bram Moolenaar | 6c89686 | 2016-11-17 19:46:51 +0100 | [diff] [blame] | 136 | |
Bram Moolenaar | 04958cb | 2018-06-23 19:23:02 +0200 | [diff] [blame] | 137 | func Test_breakindent04_vartabs() |
| 138 | " breakindent set with min width 18 |
| 139 | if !has("vartabs") |
| 140 | return |
| 141 | endif |
| 142 | call s:test_windows('setl sbr= briopt=min:18 vts=4') |
| 143 | let lines = s:screen_lines(line('.'),8) |
| 144 | let expect = [ |
| 145 | \ " abcd", |
| 146 | \ " qrstuv", |
| 147 | \ " IJKLMN", |
| 148 | \ ] |
| 149 | call s:compare_lines(expect, lines) |
| 150 | " clean up |
| 151 | call s:close_windows('set sbr= vts&') |
| 152 | endfunc |
| 153 | |
| 154 | func Test_breakindent05() |
Bram Moolenaar | 6c89686 | 2016-11-17 19:46:51 +0100 | [diff] [blame] | 155 | " breakindent set and shift by 2 |
Bram Moolenaar | 544d3bc | 2017-02-05 21:14:50 +0100 | [diff] [blame] | 156 | call s:test_windows('setl briopt=shift:2,min:0') |
Bram Moolenaar | 04958cb | 2018-06-23 19:23:02 +0200 | [diff] [blame] | 157 | let lines = s:screen_lines(line('.'),8) |
| 158 | let expect = [ |
| 159 | \ " abcd", |
| 160 | \ " qr", |
| 161 | \ " EF", |
| 162 | \ ] |
Bram Moolenaar | 544d3bc | 2017-02-05 21:14:50 +0100 | [diff] [blame] | 163 | call s:compare_lines(expect, lines) |
Bram Moolenaar | 6c89686 | 2016-11-17 19:46:51 +0100 | [diff] [blame] | 164 | call s:close_windows() |
Bram Moolenaar | 04958cb | 2018-06-23 19:23:02 +0200 | [diff] [blame] | 165 | endfunc |
Bram Moolenaar | 6c89686 | 2016-11-17 19:46:51 +0100 | [diff] [blame] | 166 | |
Bram Moolenaar | 04958cb | 2018-06-23 19:23:02 +0200 | [diff] [blame] | 167 | func Test_breakindent05_vartabs() |
| 168 | " breakindent set and shift by 2 |
| 169 | if !has("vartabs") |
| 170 | return |
| 171 | endif |
| 172 | call s:test_windows('setl briopt=shift:2,min:0 vts=4') |
| 173 | let lines = s:screen_lines(line('.'),8) |
| 174 | let expect = [ |
| 175 | \ " abcd", |
| 176 | \ " qr", |
| 177 | \ " EF", |
| 178 | \ ] |
| 179 | call s:compare_lines(expect, lines) |
| 180 | call s:close_windows('set vts&') |
| 181 | endfunc |
| 182 | |
| 183 | func Test_breakindent06() |
Bram Moolenaar | 6c89686 | 2016-11-17 19:46:51 +0100 | [diff] [blame] | 184 | " breakindent set and shift by -1 |
Bram Moolenaar | 544d3bc | 2017-02-05 21:14:50 +0100 | [diff] [blame] | 185 | call s:test_windows('setl briopt=shift:-1,min:0') |
Bram Moolenaar | 04958cb | 2018-06-23 19:23:02 +0200 | [diff] [blame] | 186 | let lines = s:screen_lines(line('.'),8) |
| 187 | let expect = [ |
| 188 | \ " abcd", |
| 189 | \ " qrstu", |
| 190 | \ " HIJKL", |
| 191 | \ ] |
Bram Moolenaar | 544d3bc | 2017-02-05 21:14:50 +0100 | [diff] [blame] | 192 | call s:compare_lines(expect, lines) |
Bram Moolenaar | 6c89686 | 2016-11-17 19:46:51 +0100 | [diff] [blame] | 193 | call s:close_windows() |
Bram Moolenaar | 04958cb | 2018-06-23 19:23:02 +0200 | [diff] [blame] | 194 | endfunc |
Bram Moolenaar | 6c89686 | 2016-11-17 19:46:51 +0100 | [diff] [blame] | 195 | |
Bram Moolenaar | 04958cb | 2018-06-23 19:23:02 +0200 | [diff] [blame] | 196 | func Test_breakindent06_vartabs() |
| 197 | " breakindent set and shift by -1 |
| 198 | if !has("vartabs") |
| 199 | return |
| 200 | endif |
| 201 | call s:test_windows('setl briopt=shift:-1,min:0 vts=4') |
| 202 | let lines = s:screen_lines(line('.'),8) |
| 203 | let expect = [ |
| 204 | \ " abcd", |
| 205 | \ " qrstu", |
| 206 | \ " HIJKL", |
| 207 | \ ] |
| 208 | call s:compare_lines(expect, lines) |
| 209 | call s:close_windows('set vts&') |
| 210 | endfunc |
| 211 | |
| 212 | func Test_breakindent07() |
Bram Moolenaar | 6c89686 | 2016-11-17 19:46:51 +0100 | [diff] [blame] | 213 | " breakindent set and shift by 1, Number set sbr=? and briopt:sbr |
Bram Moolenaar | 544d3bc | 2017-02-05 21:14:50 +0100 | [diff] [blame] | 214 | 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] | 215 | let lines = s:screen_lines(line('.'),10) |
| 216 | let expect = [ |
| 217 | \ " 2 ab", |
| 218 | \ "? m", |
| 219 | \ "? x", |
| 220 | \ ] |
Bram Moolenaar | 544d3bc | 2017-02-05 21:14:50 +0100 | [diff] [blame] | 221 | call s:compare_lines(expect, lines) |
Bram Moolenaar | 6c89686 | 2016-11-17 19:46:51 +0100 | [diff] [blame] | 222 | " clean up |
| 223 | call s:close_windows('set sbr= cpo-=n') |
Bram Moolenaar | 04958cb | 2018-06-23 19:23:02 +0200 | [diff] [blame] | 224 | endfunc |
Bram Moolenaar | 6c89686 | 2016-11-17 19:46:51 +0100 | [diff] [blame] | 225 | |
Bram Moolenaar | 04958cb | 2018-06-23 19:23:02 +0200 | [diff] [blame] | 226 | func Test_breakindent07_vartabs() |
| 227 | if !has("vartabs") |
| 228 | return |
| 229 | endif |
| 230 | " breakindent set and shift by 1, Number set sbr=? and briopt:sbr |
| 231 | call s:test_windows('setl briopt=shift:1,sbr,min:0 nu sbr=? nuw=4 cpo+=n vts=4') |
| 232 | let lines = s:screen_lines(line('.'),10) |
| 233 | let expect = [ |
| 234 | \ " 2 ab", |
| 235 | \ "? m", |
| 236 | \ "? x", |
| 237 | \ ] |
| 238 | call s:compare_lines(expect, lines) |
| 239 | " clean up |
| 240 | call s:close_windows('set sbr= cpo-=n vts&') |
| 241 | endfunc |
| 242 | |
| 243 | func Test_breakindent07a() |
Bram Moolenaar | 6c89686 | 2016-11-17 19:46:51 +0100 | [diff] [blame] | 244 | " breakindent set and shift by 1, Number set sbr=? and briopt:sbr |
Bram Moolenaar | 544d3bc | 2017-02-05 21:14:50 +0100 | [diff] [blame] | 245 | 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] | 246 | let lines = s:screen_lines(line('.'),10) |
| 247 | let expect = [ |
| 248 | \ " 2 ab", |
| 249 | \ " ? m", |
| 250 | \ " ? x", |
| 251 | \ ] |
Bram Moolenaar | 544d3bc | 2017-02-05 21:14:50 +0100 | [diff] [blame] | 252 | call s:compare_lines(expect, lines) |
Bram Moolenaar | 6c89686 | 2016-11-17 19:46:51 +0100 | [diff] [blame] | 253 | " clean up |
| 254 | call s:close_windows('set sbr=') |
Bram Moolenaar | 04958cb | 2018-06-23 19:23:02 +0200 | [diff] [blame] | 255 | endfunc |
Bram Moolenaar | 6c89686 | 2016-11-17 19:46:51 +0100 | [diff] [blame] | 256 | |
Bram Moolenaar | 04958cb | 2018-06-23 19:23:02 +0200 | [diff] [blame] | 257 | func Test_breakindent07a_vartabs() |
| 258 | if !has("vartabs") |
| 259 | return |
| 260 | endif |
| 261 | " breakindent set and shift by 1, Number set sbr=? and briopt:sbr |
| 262 | call s:test_windows('setl briopt=shift:1,sbr,min:0 nu sbr=? nuw=4 vts=4') |
| 263 | let lines = s:screen_lines(line('.'),10) |
| 264 | let expect = [ |
| 265 | \ " 2 ab", |
| 266 | \ " ? m", |
| 267 | \ " ? x", |
| 268 | \ ] |
| 269 | call s:compare_lines(expect, lines) |
| 270 | " clean up |
| 271 | call s:close_windows('set sbr= vts&') |
| 272 | endfunc |
| 273 | |
| 274 | func Test_breakindent08() |
Bram Moolenaar | 6c89686 | 2016-11-17 19:46:51 +0100 | [diff] [blame] | 275 | " 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] | 276 | 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] | 277 | " make sure, cache is invalidated! |
| 278 | set ts=8 |
| 279 | redraw! |
| 280 | set ts=4 |
| 281 | redraw! |
Bram Moolenaar | 04958cb | 2018-06-23 19:23:02 +0200 | [diff] [blame] | 282 | let lines = s:screen_lines(line('.'),10) |
| 283 | let expect = [ |
| 284 | \ " 2 ^Iabcd", |
| 285 | \ "# opq", |
| 286 | \ "# BCD", |
| 287 | \ ] |
Bram Moolenaar | 544d3bc | 2017-02-05 21:14:50 +0100 | [diff] [blame] | 288 | call s:compare_lines(expect, lines) |
Bram Moolenaar | 6c89686 | 2016-11-17 19:46:51 +0100 | [diff] [blame] | 289 | call s:close_windows('set sbr= cpo-=n') |
Bram Moolenaar | 04958cb | 2018-06-23 19:23:02 +0200 | [diff] [blame] | 290 | endfunc |
Bram Moolenaar | 6c89686 | 2016-11-17 19:46:51 +0100 | [diff] [blame] | 291 | |
Bram Moolenaar | 04958cb | 2018-06-23 19:23:02 +0200 | [diff] [blame] | 292 | func Test_breakindent08_vartabs() |
| 293 | if !has("vartabs") |
| 294 | return |
| 295 | endif |
| 296 | " breakindent set and shift by 1, Number and list set sbr=# and briopt:sbr |
| 297 | call s:test_windows('setl briopt=shift:1,sbr,min:0 nu nuw=4 sbr=# list cpo+=n ts=4 vts=4') |
| 298 | " make sure, cache is invalidated! |
| 299 | set ts=8 |
| 300 | redraw! |
| 301 | set ts=4 |
| 302 | redraw! |
| 303 | let lines = s:screen_lines(line('.'),10) |
| 304 | let expect = [ |
| 305 | \ " 2 ^Iabcd", |
| 306 | \ "# opq", |
| 307 | \ "# BCD", |
| 308 | \ ] |
| 309 | call s:compare_lines(expect, lines) |
| 310 | call s:close_windows('set sbr= cpo-=n vts&') |
| 311 | endfunc |
| 312 | |
| 313 | func Test_breakindent08a() |
Bram Moolenaar | 6c89686 | 2016-11-17 19:46:51 +0100 | [diff] [blame] | 314 | " 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] | 315 | 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] | 316 | let lines = s:screen_lines(line('.'),10) |
| 317 | let expect = [ |
| 318 | \ " 2 ^Iabcd", |
| 319 | \ " # opq", |
| 320 | \ " # BCD", |
| 321 | \ ] |
Bram Moolenaar | 544d3bc | 2017-02-05 21:14:50 +0100 | [diff] [blame] | 322 | call s:compare_lines(expect, lines) |
Bram Moolenaar | 6c89686 | 2016-11-17 19:46:51 +0100 | [diff] [blame] | 323 | call s:close_windows('set sbr=') |
Bram Moolenaar | 04958cb | 2018-06-23 19:23:02 +0200 | [diff] [blame] | 324 | endfunc |
Bram Moolenaar | 6c89686 | 2016-11-17 19:46:51 +0100 | [diff] [blame] | 325 | |
Bram Moolenaar | 04958cb | 2018-06-23 19:23:02 +0200 | [diff] [blame] | 326 | func Test_breakindent08a_vartabs() |
| 327 | if !has("vartabs") |
| 328 | return |
| 329 | endif |
| 330 | " breakindent set and shift by 1, Number and list set sbr=# and briopt:sbr |
| 331 | call s:test_windows('setl briopt=shift:1,sbr,min:0 nu nuw=4 sbr=# list vts=4') |
| 332 | let lines = s:screen_lines(line('.'),10) |
| 333 | let expect = [ |
| 334 | \ " 2 ^Iabcd", |
| 335 | \ " # opq", |
| 336 | \ " # BCD", |
| 337 | \ ] |
| 338 | call s:compare_lines(expect, lines) |
| 339 | call s:close_windows('set sbr= vts&') |
| 340 | endfunc |
| 341 | |
| 342 | func Test_breakindent09() |
Bram Moolenaar | 6c89686 | 2016-11-17 19:46:51 +0100 | [diff] [blame] | 343 | " breakindent set and shift by 1, Number and list set sbr=# |
Bram Moolenaar | 544d3bc | 2017-02-05 21:14:50 +0100 | [diff] [blame] | 344 | 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] | 345 | let lines = s:screen_lines(line('.'),10) |
| 346 | let expect = [ |
| 347 | \ " 2 ^Iabcd", |
| 348 | \ " #op", |
| 349 | \ " #AB", |
| 350 | \ ] |
Bram Moolenaar | 544d3bc | 2017-02-05 21:14:50 +0100 | [diff] [blame] | 351 | call s:compare_lines(expect, lines) |
Bram Moolenaar | 6c89686 | 2016-11-17 19:46:51 +0100 | [diff] [blame] | 352 | call s:close_windows('set sbr=') |
Bram Moolenaar | 04958cb | 2018-06-23 19:23:02 +0200 | [diff] [blame] | 353 | endfunc |
Bram Moolenaar | 6c89686 | 2016-11-17 19:46:51 +0100 | [diff] [blame] | 354 | |
Bram Moolenaar | 04958cb | 2018-06-23 19:23:02 +0200 | [diff] [blame] | 355 | func Test_breakindent09_vartabs() |
| 356 | if !has("vartabs") |
| 357 | return |
| 358 | endif |
| 359 | " breakindent set and shift by 1, Number and list set sbr=# |
| 360 | call s:test_windows('setl briopt=shift:1,min:0 nu nuw=4 sbr=# list vts=4') |
| 361 | let lines = s:screen_lines(line('.'),10) |
| 362 | let expect = [ |
| 363 | \ " 2 ^Iabcd", |
| 364 | \ " #op", |
| 365 | \ " #AB", |
| 366 | \ ] |
| 367 | call s:compare_lines(expect, lines) |
| 368 | call s:close_windows('set sbr= vts&') |
| 369 | endfunc |
| 370 | |
| 371 | func Test_breakindent10() |
Bram Moolenaar | 6c89686 | 2016-11-17 19:46:51 +0100 | [diff] [blame] | 372 | " breakindent set, Number set sbr=~ |
Bram Moolenaar | 544d3bc | 2017-02-05 21:14:50 +0100 | [diff] [blame] | 373 | 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] | 374 | " make sure, cache is invalidated! |
| 375 | set ts=8 |
| 376 | redraw! |
| 377 | set ts=4 |
| 378 | redraw! |
Bram Moolenaar | 04958cb | 2018-06-23 19:23:02 +0200 | [diff] [blame] | 379 | let lines = s:screen_lines(line('.'),10) |
| 380 | let expect = [ |
| 381 | \ " 2 ab", |
| 382 | \ "~ mn", |
| 383 | \ "~ yz", |
| 384 | \ ] |
Bram Moolenaar | 544d3bc | 2017-02-05 21:14:50 +0100 | [diff] [blame] | 385 | call s:compare_lines(expect, lines) |
Bram Moolenaar | 6c89686 | 2016-11-17 19:46:51 +0100 | [diff] [blame] | 386 | call s:close_windows('set sbr= cpo-=n') |
Bram Moolenaar | 04958cb | 2018-06-23 19:23:02 +0200 | [diff] [blame] | 387 | endfunc |
Bram Moolenaar | 6c89686 | 2016-11-17 19:46:51 +0100 | [diff] [blame] | 388 | |
Bram Moolenaar | 04958cb | 2018-06-23 19:23:02 +0200 | [diff] [blame] | 389 | func Test_breakindent10_vartabs() |
| 390 | if !has("vartabs") |
| 391 | return |
| 392 | endif |
| 393 | " breakindent set, Number set sbr=~ |
| 394 | call s:test_windows('setl cpo+=n sbr=~ nu nuw=4 nolist briopt=sbr,min:0 vts=4') |
| 395 | " make sure, cache is invalidated! |
| 396 | set ts=8 |
| 397 | redraw! |
| 398 | set ts=4 |
| 399 | redraw! |
| 400 | let lines = s:screen_lines(line('.'),10) |
| 401 | let expect = [ |
| 402 | \ " 2 ab", |
| 403 | \ "~ mn", |
| 404 | \ "~ yz", |
| 405 | \ ] |
| 406 | call s:compare_lines(expect, lines) |
| 407 | call s:close_windows('set sbr= cpo-=n vts&') |
| 408 | endfunc |
| 409 | |
| 410 | func Test_breakindent11() |
Bram Moolenaar | 6c89686 | 2016-11-17 19:46:51 +0100 | [diff] [blame] | 411 | " test strdisplaywidth() |
Bram Moolenaar | 544d3bc | 2017-02-05 21:14:50 +0100 | [diff] [blame] | 412 | 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] | 413 | let text = getline(2) |
Bram Moolenaar | f9f24ce | 2019-08-31 21:17:39 +0200 | [diff] [blame] | 414 | 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] | 415 | call assert_equal(width, strdisplaywidth(text)) |
| 416 | call s:close_windows('set sbr=') |
Bram Moolenaar | 04958cb | 2018-06-23 19:23:02 +0200 | [diff] [blame] | 417 | endfunc |
Bram Moolenaar | 6c89686 | 2016-11-17 19:46:51 +0100 | [diff] [blame] | 418 | |
Bram Moolenaar | 04958cb | 2018-06-23 19:23:02 +0200 | [diff] [blame] | 419 | func Test_breakindent11_vartabs() |
| 420 | if !has("vartabs") |
| 421 | return |
| 422 | endif |
| 423 | " test strdisplaywidth() |
| 424 | call s:test_windows('setl cpo-=n sbr=>> nu nuw=4 nolist briopt= ts=4 vts=4') |
| 425 | let text = getline(2) |
Bram Moolenaar | f9f24ce | 2019-08-31 21:17:39 +0200 | [diff] [blame] | 426 | 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] | 427 | call assert_equal(width, text->strdisplaywidth()) |
Bram Moolenaar | 04958cb | 2018-06-23 19:23:02 +0200 | [diff] [blame] | 428 | call s:close_windows('set sbr= vts&') |
| 429 | endfunc |
| 430 | |
| 431 | func Test_breakindent12() |
Bram Moolenaar | 6c89686 | 2016-11-17 19:46:51 +0100 | [diff] [blame] | 432 | " test breakindent with long indent |
Bram Moolenaar | 04958cb | 2018-06-23 19:23:02 +0200 | [diff] [blame] | 433 | let s:input = "\t\t\t\t\t{" |
Bram Moolenaar | 544d3bc | 2017-02-05 21:14:50 +0100 | [diff] [blame] | 434 | 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] | 435 | let lines = s:screen_lines(2,16) |
| 436 | let expect = [ |
| 437 | \ " 2 >--->--->--->", |
| 438 | \ " ---{ ", |
| 439 | \ "~ ", |
| 440 | \ ] |
Bram Moolenaar | 544d3bc | 2017-02-05 21:14:50 +0100 | [diff] [blame] | 441 | call s:compare_lines(expect, lines) |
Bram Moolenaar | 6c89686 | 2016-11-17 19:46:51 +0100 | [diff] [blame] | 442 | call s:close_windows('set nuw=4 listchars=') |
Bram Moolenaar | 04958cb | 2018-06-23 19:23:02 +0200 | [diff] [blame] | 443 | endfunc |
Bram Moolenaar | 6c89686 | 2016-11-17 19:46:51 +0100 | [diff] [blame] | 444 | |
Bram Moolenaar | 04958cb | 2018-06-23 19:23:02 +0200 | [diff] [blame] | 445 | func Test_breakindent12_vartabs() |
| 446 | if !has("vartabs") |
| 447 | return |
| 448 | endif |
| 449 | " test breakindent with long indent |
| 450 | let s:input = "\t\t\t\t\t{" |
| 451 | call s:test_windows('setl breakindent linebreak briopt=min:10 nu numberwidth=3 ts=4 list listchars=tab:>- vts=4') |
| 452 | let lines = s:screen_lines(2,16) |
| 453 | let expect = [ |
| 454 | \ " 2 >--->--->--->", |
| 455 | \ " ---{ ", |
| 456 | \ "~ ", |
| 457 | \ ] |
| 458 | call s:compare_lines(expect, lines) |
| 459 | call s:close_windows('set nuw=4 listchars= vts&') |
| 460 | endfunc |
| 461 | |
| 462 | func Test_breakindent13() |
| 463 | let s:input = "" |
Bram Moolenaar | 544d3bc | 2017-02-05 21:14:50 +0100 | [diff] [blame] | 464 | call s:test_windows('setl breakindent briopt=min:10 ts=8') |
Bram Moolenaar | 6c89686 | 2016-11-17 19:46:51 +0100 | [diff] [blame] | 465 | vert resize 20 |
| 466 | call setline(1, [" a\tb\tc\td\te", " z y x w v"]) |
| 467 | 1 |
| 468 | norm! fbgj"ayl |
| 469 | 2 |
| 470 | norm! fygj"byl |
| 471 | call assert_equal('d', @a) |
| 472 | call assert_equal('w', @b) |
| 473 | call s:close_windows() |
Bram Moolenaar | 04958cb | 2018-06-23 19:23:02 +0200 | [diff] [blame] | 474 | endfunc |
Bram Moolenaar | 6c89686 | 2016-11-17 19:46:51 +0100 | [diff] [blame] | 475 | |
Bram Moolenaar | 04958cb | 2018-06-23 19:23:02 +0200 | [diff] [blame] | 476 | func Test_breakindent13_vartabs() |
| 477 | if !has("vartabs") |
| 478 | return |
| 479 | endif |
| 480 | let s:input = "" |
| 481 | call s:test_windows('setl breakindent briopt=min:10 ts=8 vts=8') |
| 482 | vert resize 20 |
| 483 | call setline(1, [" a\tb\tc\td\te", " z y x w v"]) |
| 484 | 1 |
| 485 | norm! fbgj"ayl |
| 486 | 2 |
| 487 | norm! fygj"byl |
| 488 | call assert_equal('d', @a) |
| 489 | call assert_equal('w', @b) |
| 490 | call s:close_windows('set vts&') |
| 491 | endfunc |
| 492 | |
| 493 | func Test_breakindent14() |
| 494 | let s:input = "" |
Bram Moolenaar | 544d3bc | 2017-02-05 21:14:50 +0100 | [diff] [blame] | 495 | call s:test_windows('setl breakindent briopt= ts=8') |
Bram Moolenaar | 6c89686 | 2016-11-17 19:46:51 +0100 | [diff] [blame] | 496 | vert resize 30 |
| 497 | norm! 3a1234567890 |
| 498 | norm! a abcde |
| 499 | exec "norm! 0\<C-V>tex" |
Bram Moolenaar | 04958cb | 2018-06-23 19:23:02 +0200 | [diff] [blame] | 500 | let lines = s:screen_lines(line('.'),8) |
| 501 | let expect = [ |
| 502 | \ "e ", |
| 503 | \ "~ ", |
| 504 | \ "~ ", |
| 505 | \ ] |
Bram Moolenaar | 544d3bc | 2017-02-05 21:14:50 +0100 | [diff] [blame] | 506 | call s:compare_lines(expect, lines) |
Bram Moolenaar | 6c89686 | 2016-11-17 19:46:51 +0100 | [diff] [blame] | 507 | call s:close_windows() |
Bram Moolenaar | 04958cb | 2018-06-23 19:23:02 +0200 | [diff] [blame] | 508 | endfunc |
Bram Moolenaar | 6c89686 | 2016-11-17 19:46:51 +0100 | [diff] [blame] | 509 | |
Bram Moolenaar | 04958cb | 2018-06-23 19:23:02 +0200 | [diff] [blame] | 510 | func Test_breakindent14_vartabs() |
| 511 | if !has("vartabs") |
| 512 | return |
| 513 | endif |
| 514 | let s:input = "" |
| 515 | call s:test_windows('setl breakindent briopt= ts=8 vts=8') |
| 516 | vert resize 30 |
| 517 | norm! 3a1234567890 |
| 518 | norm! a abcde |
| 519 | exec "norm! 0\<C-V>tex" |
| 520 | let lines = s:screen_lines(line('.'),8) |
| 521 | let expect = [ |
| 522 | \ "e ", |
| 523 | \ "~ ", |
| 524 | \ "~ ", |
| 525 | \ ] |
| 526 | call s:compare_lines(expect, lines) |
| 527 | call s:close_windows('set vts&') |
| 528 | endfunc |
| 529 | |
| 530 | func Test_breakindent15() |
| 531 | let s:input = "" |
Bram Moolenaar | 544d3bc | 2017-02-05 21:14:50 +0100 | [diff] [blame] | 532 | call s:test_windows('setl breakindent briopt= ts=8 sw=8') |
Bram Moolenaar | 6c89686 | 2016-11-17 19:46:51 +0100 | [diff] [blame] | 533 | vert resize 30 |
| 534 | norm! 4a1234567890 |
| 535 | exe "normal! >>\<C-V>3f0x" |
Bram Moolenaar | 04958cb | 2018-06-23 19:23:02 +0200 | [diff] [blame] | 536 | let lines = s:screen_lines(line('.'),20) |
| 537 | let expect = [ |
| 538 | \ " 1234567890 ", |
| 539 | \ "~ ", |
| 540 | \ "~ ", |
| 541 | \ ] |
Bram Moolenaar | 544d3bc | 2017-02-05 21:14:50 +0100 | [diff] [blame] | 542 | call s:compare_lines(expect, lines) |
Bram Moolenaar | 6c89686 | 2016-11-17 19:46:51 +0100 | [diff] [blame] | 543 | call s:close_windows() |
Bram Moolenaar | 04958cb | 2018-06-23 19:23:02 +0200 | [diff] [blame] | 544 | endfunc |
Bram Moolenaar | 6c89686 | 2016-11-17 19:46:51 +0100 | [diff] [blame] | 545 | |
Bram Moolenaar | 04958cb | 2018-06-23 19:23:02 +0200 | [diff] [blame] | 546 | func Test_breakindent15_vartabs() |
| 547 | if !has("vartabs") |
| 548 | return |
| 549 | endif |
| 550 | let s:input = "" |
| 551 | call s:test_windows('setl breakindent briopt= ts=8 sw=8 vts=8') |
| 552 | vert resize 30 |
| 553 | norm! 4a1234567890 |
| 554 | exe "normal! >>\<C-V>3f0x" |
| 555 | let lines = s:screen_lines(line('.'),20) |
| 556 | let expect = [ |
| 557 | \ " 1234567890 ", |
| 558 | \ "~ ", |
| 559 | \ "~ ", |
| 560 | \ ] |
| 561 | call s:compare_lines(expect, lines) |
| 562 | call s:close_windows('set vts&') |
| 563 | endfunc |
| 564 | |
| 565 | func Test_breakindent16() |
Bram Moolenaar | 6c89686 | 2016-11-17 19:46:51 +0100 | [diff] [blame] | 566 | " Check that overlong lines are indented correctly. |
Bram Moolenaar | 04958cb | 2018-06-23 19:23:02 +0200 | [diff] [blame] | 567 | let s:input = "" |
Bram Moolenaar | 544d3bc | 2017-02-05 21:14:50 +0100 | [diff] [blame] | 568 | call s:test_windows('setl breakindent briopt=min:0 ts=4') |
Bram Moolenaar | 6c89686 | 2016-11-17 19:46:51 +0100 | [diff] [blame] | 569 | call setline(1, "\t".repeat("1234567890", 10)) |
| 570 | resize 6 |
| 571 | norm! 1gg$ |
| 572 | redraw! |
Bram Moolenaar | 04958cb | 2018-06-23 19:23:02 +0200 | [diff] [blame] | 573 | let lines = s:screen_lines(1,10) |
| 574 | let expect = [ |
| 575 | \ " 789012", |
| 576 | \ " 345678", |
| 577 | \ " 901234", |
| 578 | \ ] |
Bram Moolenaar | 544d3bc | 2017-02-05 21:14:50 +0100 | [diff] [blame] | 579 | call s:compare_lines(expect, lines) |
Bram Moolenaar | 04958cb | 2018-06-23 19:23:02 +0200 | [diff] [blame] | 580 | let lines = s:screen_lines(4,10) |
| 581 | let expect = [ |
| 582 | \ " 567890", |
| 583 | \ " 123456", |
| 584 | \ " 7890 ", |
| 585 | \ ] |
Bram Moolenaar | 544d3bc | 2017-02-05 21:14:50 +0100 | [diff] [blame] | 586 | call s:compare_lines(expect, lines) |
Bram Moolenaar | 6c89686 | 2016-11-17 19:46:51 +0100 | [diff] [blame] | 587 | call s:close_windows() |
Bram Moolenaar | 04958cb | 2018-06-23 19:23:02 +0200 | [diff] [blame] | 588 | endfunc |
| 589 | |
| 590 | func Test_breakindent16_vartabs() |
| 591 | if !has("vartabs") |
| 592 | return |
| 593 | endif |
| 594 | " Check that overlong lines are indented correctly. |
| 595 | let s:input = "" |
| 596 | call s:test_windows('setl breakindent briopt=min:0 ts=4 vts=4') |
| 597 | call setline(1, "\t".repeat("1234567890", 10)) |
| 598 | resize 6 |
| 599 | norm! 1gg$ |
| 600 | redraw! |
| 601 | let lines = s:screen_lines(1,10) |
| 602 | let expect = [ |
| 603 | \ " 789012", |
| 604 | \ " 345678", |
| 605 | \ " 901234", |
| 606 | \ ] |
| 607 | call s:compare_lines(expect, lines) |
| 608 | let lines = s:screen_lines(4,10) |
| 609 | let expect = [ |
| 610 | \ " 567890", |
| 611 | \ " 123456", |
| 612 | \ " 7890 ", |
| 613 | \ ] |
| 614 | call s:compare_lines(expect, lines) |
| 615 | call s:close_windows('set vts&') |
| 616 | endfunc |
Bram Moolenaar | 2f7b7b1 | 2019-11-03 15:46:48 +0100 | [diff] [blame] | 617 | |
| 618 | func Test_breakindent17_vartabs() |
| 619 | if !has("vartabs") |
| 620 | return |
| 621 | endif |
| 622 | let s:input = "" |
| 623 | call s:test_windows('setl breakindent list listchars=tab:<-> showbreak=+++') |
| 624 | call setline(1, "\t" . repeat('a', 63)) |
| 625 | vert resize 30 |
| 626 | norm! 1gg$ |
| 627 | redraw! |
| 628 | let lines = s:screen_lines(1, 30) |
| 629 | let expect = [ |
| 630 | \ "<-->aaaaaaaaaaaaaaaaaaaaaaaaaa", |
| 631 | \ " +++aaaaaaaaaaaaaaaaaaaaaaa", |
| 632 | \ " +++aaaaaaaaaaaaaa ", |
| 633 | \ ] |
| 634 | call s:compare_lines(expect, lines) |
| 635 | call s:close_windows('set breakindent& list& listchars& showbreak&') |
| 636 | endfunc |
| 637 | |
| 638 | func Test_breakindent18_vartabs() |
| 639 | if !has("vartabs") |
| 640 | return |
| 641 | endif |
| 642 | let s:input = "" |
| 643 | call s:test_windows('setl breakindent list listchars=tab:<->') |
| 644 | call setline(1, "\t" . repeat('a', 63)) |
| 645 | vert resize 30 |
| 646 | norm! 1gg$ |
| 647 | redraw! |
| 648 | let lines = s:screen_lines(1, 30) |
| 649 | let expect = [ |
| 650 | \ "<-->aaaaaaaaaaaaaaaaaaaaaaaaaa", |
| 651 | \ " aaaaaaaaaaaaaaaaaaaaaaaaaa", |
| 652 | \ " aaaaaaaaaaa ", |
| 653 | \ ] |
| 654 | call s:compare_lines(expect, lines) |
| 655 | call s:close_windows('set breakindent& list& listchars&') |
| 656 | endfunc |
| 657 | |