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