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