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