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 | CheckOption breakindent |
Bram Moolenaar | 6c89686 | 2016-11-17 19:46:51 +0100 | [diff] [blame] | 8 | |
Christian Brabandt | eb380b9 | 2025-07-07 20:53:55 +0200 | [diff] [blame] | 9 | source util/screendump.vim |
Bram Moolenaar | 544d3bc | 2017-02-05 21:14:50 +0100 | [diff] [blame] | 10 | |
Bram Moolenaar | fa4873c | 2022-06-30 22:13:59 +0100 | [diff] [blame] | 11 | func SetUp() |
| 12 | let s:input ="\tabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOP" |
| 13 | endfunc |
Bram Moolenaar | 6c89686 | 2016-11-17 19:46:51 +0100 | [diff] [blame] | 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') |
Bram Moolenaar | 0466d39 | 2022-10-03 17:07:34 +0100 | [diff] [blame] | 84 | let lines = s:screen_lines(line('.'), 8) |
Bram Moolenaar | 04958cb | 2018-06-23 19:23:02 +0200 | [diff] [blame] | 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 | 0466d39 | 2022-10-03 17:07:34 +0100 | [diff] [blame] | 97 | let lines = s:screen_lines(line('.'), 8) |
Bram Moolenaar | 04958cb | 2018-06-23 19:23:02 +0200 | [diff] [blame] | 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') |
Bram Moolenaar | 0466d39 | 2022-10-03 17:07:34 +0100 | [diff] [blame] | 112 | let lines = s:screen_lines(line('.'), 8) |
Bram Moolenaar | 04958cb | 2018-06-23 19:23:02 +0200 | [diff] [blame] | 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 | 0466d39 | 2022-10-03 17:07:34 +0100 | [diff] [blame] | 127 | let lines = s:screen_lines(line('.'), 8) |
Bram Moolenaar | 04958cb | 2018-06-23 19:23:02 +0200 | [diff] [blame] | 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') |
Bram Moolenaar | 0466d39 | 2022-10-03 17:07:34 +0100 | [diff] [blame] | 143 | let lines = s:screen_lines(line('.'), 8) |
Bram Moolenaar | 04958cb | 2018-06-23 19:23:02 +0200 | [diff] [blame] | 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) |
zeertzjq | efabd7c | 2024-02-11 17:16:19 +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) |
zeertzjq | efabd7c | 2024-02-11 17:16:19 +0100 | [diff] [blame] | 440 | call s:close_windows('set nuw=4 listchars& vts&') |
Bram Moolenaar | 04958cb | 2018-06-23 19:23:02 +0200 | [diff] [blame] | 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 = [ |
Bram Moolenaar | 0466d39 | 2022-10-03 17:07:34 +0100 | [diff] [blame] | 550 | \ "<<< 789012", |
Bram Moolenaar | 04958cb | 2018-06-23 19:23:02 +0200 | [diff] [blame] | 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 = [ |
Bram Moolenaar | 0466d39 | 2022-10-03 17:07:34 +0100 | [diff] [blame] | 576 | \ "<<< 789012", |
Bram Moolenaar | 04958cb | 2018-06-23 19:23:02 +0200 | [diff] [blame] | 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 = [ |
Bram Moolenaar | 0937b9f | 2022-10-06 21:24:34 +0100 | [diff] [blame] | 661 | \ ">aaaaaaaaaaaaaaaaaaa", |
Bram Moolenaar | 1aa76b8 | 2020-02-23 15:17:27 +0100 | [diff] [blame] | 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') |
Bram Moolenaar | 06618f9 | 2022-10-06 19:21:20 +0100 | [diff] [blame] | 672 | call setline(1, repeat('abcdefghijklmnopqrst', 10)) |
Bram Moolenaar | e882f7a | 2020-05-16 14:07:39 +0200 | [diff] [blame] | 673 | norm! 1gg |
| 674 | redraw! |
| 675 | let lines = s:screen_lines(1, 20) |
| 676 | let expect = [ |
Bram Moolenaar | 06618f9 | 2022-10-06 19:21:20 +0100 | [diff] [blame] | 677 | \ " 1 abcdefghijklmnop", |
| 678 | \ " qrstabcdefghijkl", |
| 679 | \ " mnopqrstabcdefgh", |
Bram Moolenaar | e882f7a | 2020-05-16 14:07:39 +0200 | [diff] [blame] | 680 | \ ] |
| 681 | call s:compare_lines(expect, lines) |
| 682 | " Scroll down one screen line |
| 683 | setl scrolloff=5 |
Bram Moolenaar | 856c5d2 | 2022-10-13 21:54:28 +0100 | [diff] [blame] | 684 | norm! 6gj |
Bram Moolenaar | e882f7a | 2020-05-16 14:07:39 +0200 | [diff] [blame] | 685 | redraw! |
| 686 | let lines = s:screen_lines(1, 20) |
| 687 | let expect = [ |
Bram Moolenaar | 06618f9 | 2022-10-06 19:21:20 +0100 | [diff] [blame] | 688 | \ "<<< qrstabcdefghijkl", |
| 689 | \ " mnopqrstabcdefgh", |
| 690 | \ " ijklmnopqrstabcd", |
Bram Moolenaar | e882f7a | 2020-05-16 14:07:39 +0200 | [diff] [blame] | 691 | \ ] |
Bram Moolenaar | 856c5d2 | 2022-10-13 21:54:28 +0100 | [diff] [blame] | 692 | call s:compare_lines(expect, lines) |
Bram Moolenaar | e882f7a | 2020-05-16 14:07:39 +0200 | [diff] [blame] | 693 | |
| 694 | setl briopt+=shift:2 |
| 695 | norm! 1gg |
| 696 | let lines = s:screen_lines(1, 20) |
| 697 | let expect = [ |
Bram Moolenaar | 06618f9 | 2022-10-06 19:21:20 +0100 | [diff] [blame] | 698 | \ " 1 abcdefghijklmnop", |
| 699 | \ " qrstabcdefghij", |
| 700 | \ " klmnopqrstabcd", |
Bram Moolenaar | e882f7a | 2020-05-16 14:07:39 +0200 | [diff] [blame] | 701 | \ ] |
| 702 | call s:compare_lines(expect, lines) |
| 703 | " Scroll down one screen line |
Bram Moolenaar | 856c5d2 | 2022-10-13 21:54:28 +0100 | [diff] [blame] | 704 | norm! 6gj |
Bram Moolenaar | e882f7a | 2020-05-16 14:07:39 +0200 | [diff] [blame] | 705 | let lines = s:screen_lines(1, 20) |
| 706 | let expect = [ |
Bram Moolenaar | 06618f9 | 2022-10-06 19:21:20 +0100 | [diff] [blame] | 707 | \ "<<< qrstabcdefghij", |
| 708 | \ " klmnopqrstabcd", |
| 709 | \ " efghijklmnopqr", |
Bram Moolenaar | e882f7a | 2020-05-16 14:07:39 +0200 | [diff] [blame] | 710 | \ ] |
Bram Moolenaar | 856c5d2 | 2022-10-13 21:54:28 +0100 | [diff] [blame] | 711 | call s:compare_lines(expect, lines) |
Bram Moolenaar | e882f7a | 2020-05-16 14:07:39 +0200 | [diff] [blame] | 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) |
zeertzjq | f0a9d65 | 2024-02-12 22:53:20 +0100 | [diff] [blame] | 734 | " set minimum text width |
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) |
zeertzjq | 61a6ac4 | 2024-09-07 11:23:54 +0200 | [diff] [blame] | 798 | |
| 799 | " check with TABs |
| 800 | call setline(1, ["\t1.\tCongress shall make no law", |
| 801 | \ "\t2.) Congress shall make no law", |
| 802 | \ "\t3.] Congress shall make no law"]) |
| 803 | setl tabstop=4 list listchars=tab:<-> |
| 804 | norm! 1gg |
| 805 | redraw! |
| 806 | let expect = [ |
| 807 | \ "<-->1.<>Congress ", |
| 808 | \ " shall make ", |
| 809 | \ " no law ", |
| 810 | \ "<-->2.) Congress ", |
| 811 | \ " shall make ", |
| 812 | \ " no law ", |
| 813 | \ "<-->3.] Congress ", |
| 814 | \ " shall make ", |
| 815 | \ " no law ", |
| 816 | \ ] |
| 817 | let lines = s:screen_lines2(1, 9, 20) |
| 818 | call s:compare_lines(expect, lines) |
| 819 | |
| 820 | setl tabstop=2 nolist |
| 821 | redraw! |
| 822 | let expect = [ |
| 823 | \ " 1. Congress ", |
| 824 | \ " shall make no ", |
| 825 | \ " law ", |
| 826 | \ " 2.) Congress ", |
| 827 | \ " shall make no ", |
| 828 | \ " law ", |
| 829 | \ " 3.] Congress ", |
| 830 | \ " shall make no ", |
| 831 | \ " law ", |
| 832 | \ ] |
| 833 | let lines = s:screen_lines2(1, 9, 20) |
| 834 | call s:compare_lines(expect, lines) |
| 835 | |
| 836 | setl tabstop& list listchars=space:_ |
| 837 | redraw! |
| 838 | let expect = [ |
| 839 | \ "^I1.^ICongress_ ", |
| 840 | \ " shall_make_no_", |
| 841 | \ " law ", |
| 842 | \ "^I2.)_Congress_ ", |
| 843 | \ " shall_make_no_", |
| 844 | \ " law ", |
| 845 | \ "^I3.]_Congress_ ", |
| 846 | \ " shall_make_no_", |
| 847 | \ " law ", |
| 848 | \ ] |
| 849 | let lines = s:screen_lines2(1, 9, 20) |
| 850 | call s:compare_lines(expect, lines) |
| 851 | |
Maxim Kim | f674b35 | 2021-07-22 11:46:59 +0200 | [diff] [blame] | 852 | " check formatlistpat indent with different list levels |
zeertzjq | 61a6ac4 | 2024-09-07 11:23:54 +0200 | [diff] [blame] | 853 | let &l:flp = '^\s*\(\*\|•\)\+\s\+' |
| 854 | setl list&vim listchars&vim |
Maxim Kim | f674b35 | 2021-07-22 11:46:59 +0200 | [diff] [blame] | 855 | %delete _ |
| 856 | call setline(1, ['* Congress shall make no law', |
zeertzjq | 61a6ac4 | 2024-09-07 11:23:54 +0200 | [diff] [blame] | 857 | \ '••• Congress shall make no law', |
Maxim Kim | f674b35 | 2021-07-22 11:46:59 +0200 | [diff] [blame] | 858 | \ '**** Congress shall make no law']) |
| 859 | norm! 1gg |
Bram Moolenaar | c2a79b8 | 2022-07-01 13:15:35 +0100 | [diff] [blame] | 860 | redraw! |
Maxim Kim | f674b35 | 2021-07-22 11:46:59 +0200 | [diff] [blame] | 861 | let expect = [ |
| 862 | \ "* Congress shall ", |
| 863 | \ " make no law ", |
zeertzjq | 61a6ac4 | 2024-09-07 11:23:54 +0200 | [diff] [blame] | 864 | \ "••• Congress shall ", |
Maxim Kim | f674b35 | 2021-07-22 11:46:59 +0200 | [diff] [blame] | 865 | \ " make no law ", |
| 866 | \ "**** Congress shall ", |
| 867 | \ " make no law ", |
| 868 | \ ] |
| 869 | let lines = s:screen_lines2(1, 6, 20) |
| 870 | call s:compare_lines(expect, lines) |
| 871 | |
| 872 | " check formatlistpat indent with different list level |
| 873 | " showbreak and sbr |
Maxim Kim | 1191672 | 2022-09-02 14:08:53 +0100 | [diff] [blame] | 874 | setl briopt=min:5,sbr,list:-1 |
Maxim Kim | f674b35 | 2021-07-22 11:46:59 +0200 | [diff] [blame] | 875 | setl showbreak=> |
| 876 | redraw! |
| 877 | let expect = [ |
| 878 | \ "* Congress shall ", |
| 879 | \ "> make no law ", |
zeertzjq | 61a6ac4 | 2024-09-07 11:23:54 +0200 | [diff] [blame] | 880 | \ "••• Congress shall ", |
Maxim Kim | f674b35 | 2021-07-22 11:46:59 +0200 | [diff] [blame] | 881 | \ "> make no law ", |
| 882 | \ "**** Congress shall ", |
| 883 | \ "> make no law ", |
| 884 | \ ] |
| 885 | let lines = s:screen_lines2(1, 6, 20) |
| 886 | call s:compare_lines(expect, lines) |
Maxim Kim | 1191672 | 2022-09-02 14:08:53 +0100 | [diff] [blame] | 887 | |
| 888 | " check formatlistpat indent with different list level |
| 889 | " showbreak sbr and shift |
| 890 | setl briopt=min:5,sbr,list:-1,shift:2 |
| 891 | setl showbreak=> |
| 892 | redraw! |
| 893 | let expect = [ |
| 894 | \ "* Congress shall ", |
| 895 | \ "> make no law ", |
zeertzjq | 61a6ac4 | 2024-09-07 11:23:54 +0200 | [diff] [blame] | 896 | \ "••• Congress shall ", |
Maxim Kim | 1191672 | 2022-09-02 14:08:53 +0100 | [diff] [blame] | 897 | \ "> make no law ", |
| 898 | \ "**** Congress shall ", |
| 899 | \ "> make no law ", |
| 900 | \ ] |
| 901 | let lines = s:screen_lines2(1, 6, 20) |
| 902 | call s:compare_lines(expect, lines) |
| 903 | |
| 904 | " check breakindent works if breakindentopt=list:-1 |
| 905 | " for a non list content |
| 906 | %delete _ |
| 907 | call setline(1, [' Congress shall make no law', |
| 908 | \ ' Congress shall make no law', |
| 909 | \ ' Congress shall make no law']) |
| 910 | norm! 1gg |
| 911 | setl briopt=min:5,list:-1 |
| 912 | setl showbreak= |
| 913 | redraw! |
| 914 | let expect = [ |
| 915 | \ " Congress shall ", |
| 916 | \ " make no law ", |
| 917 | \ " Congress shall ", |
| 918 | \ " make no law ", |
| 919 | \ " Congress shall ", |
| 920 | \ " make no law ", |
| 921 | \ ] |
| 922 | let lines = s:screen_lines2(1, 6, 20) |
| 923 | call s:compare_lines(expect, lines) |
| 924 | |
Maxim Kim | f674b35 | 2021-07-22 11:46:59 +0200 | [diff] [blame] | 925 | call s:close_windows('set breakindent& briopt& linebreak& list& listchars& showbreak&') |
Christian Brabandt | 4a0b85a | 2021-07-14 20:00:27 +0200 | [diff] [blame] | 926 | endfunc |
| 927 | |
Yegappan Lakshmanan | 03d2579 | 2021-09-02 20:05:26 +0200 | [diff] [blame] | 928 | " The following used to crash Vim. This is fixed by 8.2.3391. |
| 929 | " This is a regression introduced by 8.2.2903. |
| 930 | func Test_window_resize_with_linebreak() |
| 931 | new |
| 932 | 53vnew |
Christian Brabandt | e7d6dbc | 2022-05-06 12:21:04 +0100 | [diff] [blame] | 933 | setl linebreak |
| 934 | setl showbreak=>> |
| 935 | setl breakindent |
| 936 | setl breakindentopt=shift:4 |
Yegappan Lakshmanan | 03d2579 | 2021-09-02 20:05:26 +0200 | [diff] [blame] | 937 | call setline(1, "\naaaaaaaaa\n\na\naaaaa\n¯aaaaaaaaaa\naaaaaaaaaaaa\naaa\n\"a:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa - aaaaaaaa\"\naaaaaaaa\n\"a") |
| 938 | redraw! |
| 939 | call assert_equal([" >>aa^@\"a: "], ScreenLines(2, 14)) |
| 940 | vertical resize 52 |
| 941 | redraw! |
| 942 | call assert_equal([" >>aaa^@\"a:"], ScreenLines(2, 14)) |
Christian Brabandt | e7d6dbc | 2022-05-06 12:21:04 +0100 | [diff] [blame] | 943 | set linebreak& showbreak& breakindent& breakindentopt& |
Yegappan Lakshmanan | 03d2579 | 2021-09-02 20:05:26 +0200 | [diff] [blame] | 944 | %bw! |
| 945 | endfunc |
| 946 | |
Bram Moolenaar | 21efafe | 2022-03-03 20:04:03 +0000 | [diff] [blame] | 947 | func Test_cursor_position_with_showbreak() |
| 948 | CheckScreendump |
| 949 | |
| 950 | let lines =<< trim END |
| 951 | vim9script |
| 952 | &signcolumn = 'yes' |
zeertzjq | 1193951 | 2023-08-23 20:58:01 +0200 | [diff] [blame] | 953 | &showbreak = '++' |
zeertzjq | 1193951 | 2023-08-23 20:58:01 +0200 | [diff] [blame] | 954 | &breakindentopt = 'shift:2' |
Bram Moolenaar | 21efafe | 2022-03-03 20:04:03 +0000 | [diff] [blame] | 955 | var leftcol: number = win_getid()->getwininfo()->get(0, {})->get('textoff') |
| 956 | repeat('x', &columns - leftcol - 1)->setline(1) |
| 957 | 'second line'->setline(2) |
| 958 | END |
Bram Moolenaar | 3411265 | 2022-09-05 21:40:44 +0100 | [diff] [blame] | 959 | call writefile(lines, 'XscriptShowbreak', 'D') |
Bram Moolenaar | 21efafe | 2022-03-03 20:04:03 +0000 | [diff] [blame] | 960 | let buf = RunVimInTerminal('-S XscriptShowbreak', #{rows: 6}) |
| 961 | |
| 962 | call term_sendkeys(buf, "AX") |
zeertzjq | 1193951 | 2023-08-23 20:58:01 +0200 | [diff] [blame] | 963 | call VerifyScreenDump(buf, 'Test_cursor_position_with_showbreak_1', {}) |
| 964 | " No line wraps, so changing 'showbreak' should lead to the same screen. |
| 965 | call term_sendkeys(buf, "\<C-\>\<C-O>:setlocal showbreak=+\<CR>") |
| 966 | call VerifyScreenDump(buf, 'Test_cursor_position_with_showbreak_1', {}) |
zeertzjq | 6a38972 | 2023-08-27 19:04:14 +0200 | [diff] [blame] | 967 | " No line wraps, so setting 'breakindent' should lead to the same screen. |
| 968 | call term_sendkeys(buf, "\<C-\>\<C-O>:setlocal breakindent\<CR>") |
| 969 | call VerifyScreenDump(buf, 'Test_cursor_position_with_showbreak_1', {}) |
zeertzjq | 1193951 | 2023-08-23 20:58:01 +0200 | [diff] [blame] | 970 | " The first line now wraps because of "eol" in 'listchars'. |
| 971 | call term_sendkeys(buf, "\<C-\>\<C-O>:setlocal list\<CR>") |
| 972 | call VerifyScreenDump(buf, 'Test_cursor_position_with_showbreak_2', {}) |
zeertzjq | 6a38972 | 2023-08-27 19:04:14 +0200 | [diff] [blame] | 973 | call term_sendkeys(buf, "\<C-\>\<C-O>:setlocal nobreakindent\<CR>") |
| 974 | call VerifyScreenDump(buf, 'Test_cursor_position_with_showbreak_3', {}) |
Bram Moolenaar | 21efafe | 2022-03-03 20:04:03 +0000 | [diff] [blame] | 975 | |
| 976 | call StopVimInTerminal(buf) |
Bram Moolenaar | 21efafe | 2022-03-03 20:04:03 +0000 | [diff] [blame] | 977 | endfunc |
| 978 | |
zeertzjq | 2362772 | 2023-12-27 19:08:53 +0100 | [diff] [blame] | 979 | func Test_visual_starts_before_skipcol() |
| 980 | CheckScreendump |
| 981 | |
| 982 | let lines =<< trim END |
| 983 | 1new |
| 984 | setlocal breakindent |
| 985 | call setline(1, "\t" .. join(range(100))) |
| 986 | END |
| 987 | call writefile(lines, 'XvisualStartsBeforeSkipcol', 'D') |
| 988 | let buf = RunVimInTerminal('-S XvisualStartsBeforeSkipcol', #{rows: 6}) |
| 989 | |
| 990 | call term_sendkeys(buf, "v$") |
| 991 | call VerifyScreenDump(buf, 'Test_visual_starts_before_skipcol_1', {}) |
| 992 | call term_sendkeys(buf, "\<Esc>:setlocal showbreak=+++\<CR>gv") |
| 993 | call VerifyScreenDump(buf, 'Test_visual_starts_before_skipcol_2', {}) |
| 994 | call term_sendkeys(buf, "\<Esc>:setlocal breakindentopt+=sbr\<CR>gv") |
| 995 | call VerifyScreenDump(buf, 'Test_visual_starts_before_skipcol_3', {}) |
| 996 | call term_sendkeys(buf, "\<Esc>:setlocal nobreakindent\<CR>gv") |
| 997 | call VerifyScreenDump(buf, 'Test_visual_starts_before_skipcol_4', {}) |
| 998 | |
| 999 | call StopVimInTerminal(buf) |
| 1000 | endfunc |
| 1001 | |
Christian Brabandt | c53b467 | 2022-01-15 10:01:05 +0000 | [diff] [blame] | 1002 | func Test_no_spurious_match() |
| 1003 | let s:input = printf('- y %s y %s', repeat('x', 50), repeat('x', 50)) |
| 1004 | call s:test_windows('setl breakindent breakindentopt=list:-1 formatlistpat=^- hls') |
| 1005 | let @/ = '\%>3v[y]' |
| 1006 | redraw! |
| 1007 | call searchcount().total->assert_equal(1) |
Bram Moolenaar | fa4873c | 2022-06-30 22:13:59 +0100 | [diff] [blame] | 1008 | |
Christian Brabandt | c53b467 | 2022-01-15 10:01:05 +0000 | [diff] [blame] | 1009 | " cleanup |
| 1010 | set hls&vim |
Christian Brabandt | c53b467 | 2022-01-15 10:01:05 +0000 | [diff] [blame] | 1011 | bwipeout! |
| 1012 | endfunc |
| 1013 | |
| 1014 | func Test_no_extra_indent() |
| 1015 | call s:test_windows('setl breakindent breakindentopt=list:-1,min:10') |
| 1016 | %d |
| 1017 | let &l:formatlistpat='^\s*\d\+\.\s\+' |
| 1018 | let text = 'word ' |
| 1019 | let len = text->strcharlen() |
| 1020 | let line1 = text->repeat((winwidth(0) / len) * 2) |
| 1021 | let line2 = repeat(' ', 2) .. '1. ' .. line1 |
| 1022 | call setline(1, [line2]) |
| 1023 | redraw! |
| 1024 | " 1) matches formatlist pattern, so indent |
| 1025 | let expect = [ |
| 1026 | \ " 1. word word word ", |
| 1027 | \ " word word word ", |
| 1028 | \ " word word ", |
| 1029 | \ "~ ", |
| 1030 | \ ] |
| 1031 | let lines = s:screen_lines2(1, 4, 20) |
| 1032 | call s:compare_lines(expect, lines) |
| 1033 | " 2) change formatlist pattern |
| 1034 | " -> indent adjusted |
| 1035 | let &l:formatlistpat='^\s*\d\+\.' |
| 1036 | let expect = [ |
| 1037 | \ " 1. word word word ", |
| 1038 | \ " word word word ", |
| 1039 | \ " word word ", |
| 1040 | \ "~ ", |
| 1041 | \ ] |
| 1042 | let lines = s:screen_lines2(1, 4, 20) |
Bram Moolenaar | 04b871d | 2022-01-15 18:31:43 +0000 | [diff] [blame] | 1043 | " 3) no local formatlist pattern, |
| 1044 | " so use global one -> indent |
| 1045 | let g_flp = &g:flp |
| 1046 | let &g:formatlistpat='^\s*\d\+\.\s\+' |
| 1047 | let &l:formatlistpat='' |
| 1048 | let expect = [ |
| 1049 | \ " 1. word word word ", |
| 1050 | \ " word word word ", |
| 1051 | \ " word word ", |
| 1052 | \ "~ ", |
| 1053 | \ ] |
| 1054 | let lines = s:screen_lines2(1, 4, 20) |
| 1055 | call s:compare_lines(expect, lines) |
| 1056 | let &g:flp = g_flp |
| 1057 | let &l:formatlistpat='^\s*\d\+\.' |
| 1058 | " 4) add something in front, no additional indent |
Christian Brabandt | c53b467 | 2022-01-15 10:01:05 +0000 | [diff] [blame] | 1059 | norm! gg0 |
| 1060 | exe ":norm! 5iword \<esc>" |
| 1061 | redraw! |
| 1062 | let expect = [ |
| 1063 | \ "word word word word ", |
| 1064 | \ "word 1. word word ", |
| 1065 | \ "word word word word ", |
| 1066 | \ "word word ", |
| 1067 | \ "~ ", |
| 1068 | \ ] |
| 1069 | let lines = s:screen_lines2(1, 5, 20) |
| 1070 | call s:compare_lines(expect, lines) |
| 1071 | bwipeout! |
| 1072 | endfunc |
| 1073 | |
Christian Brabandt | e7d6dbc | 2022-05-06 12:21:04 +0100 | [diff] [blame] | 1074 | func Test_breakindent_column() |
Christian Brabandt | e7d6dbc | 2022-05-06 12:21:04 +0100 | [diff] [blame] | 1075 | call s:test_windows('setl breakindent breakindentopt=column:10') |
| 1076 | redraw! |
| 1077 | " 1) default: does not indent, too wide :( |
| 1078 | let expect = [ |
| 1079 | \ " ", |
| 1080 | \ " abcdefghijklmnop", |
| 1081 | \ "qrstuvwxyzABCDEFGHIJ", |
| 1082 | \ "KLMNOP " |
| 1083 | \ ] |
| 1084 | let lines = s:screen_lines2(1, 4, 20) |
| 1085 | call s:compare_lines(expect, lines) |
| 1086 | " 2) lower min value, so that breakindent works |
| 1087 | setl breakindentopt+=min:5 |
| 1088 | redraw! |
| 1089 | let expect = [ |
| 1090 | \ " ", |
| 1091 | \ " abcdefghijklmnop", |
| 1092 | \ " qrstuvwxyz", |
| 1093 | \ " ABCDEFGHIJ", |
| 1094 | \ " KLMNOP " |
| 1095 | \ ] |
| 1096 | let lines = s:screen_lines2(1, 5, 20) |
| 1097 | " 3) set shift option -> no influence |
| 1098 | setl breakindentopt+=shift:5 |
| 1099 | redraw! |
| 1100 | let expect = [ |
| 1101 | \ " ", |
| 1102 | \ " abcdefghijklmnop", |
| 1103 | \ " qrstuvwxyz", |
| 1104 | \ " ABCDEFGHIJ", |
| 1105 | \ " KLMNOP " |
| 1106 | \ ] |
| 1107 | let lines = s:screen_lines2(1, 5, 20) |
| 1108 | call s:compare_lines(expect, lines) |
| 1109 | " 4) add showbreak value |
| 1110 | setl showbreak=++ |
| 1111 | redraw! |
| 1112 | let expect = [ |
| 1113 | \ " ", |
| 1114 | \ " abcdefghijklmnop", |
| 1115 | \ " ++qrstuvwx", |
| 1116 | \ " ++yzABCDEF", |
| 1117 | \ " ++GHIJKLMN", |
| 1118 | \ " ++OP " |
| 1119 | \ ] |
| 1120 | let lines = s:screen_lines2(1, 6, 20) |
| 1121 | call s:compare_lines(expect, lines) |
| 1122 | bwipeout! |
| 1123 | endfunc |
| 1124 | |
Bram Moolenaar | c67c89c | 2022-12-02 16:39:44 +0000 | [diff] [blame] | 1125 | func Test_linebreak_list() |
| 1126 | " This was setting wlv.c_extra to NUL while wlv.p_extra is NULL |
| 1127 | filetype plugin on |
| 1128 | syntax enable |
| 1129 | edit! $VIMRUNTIME/doc/index.txt |
| 1130 | /v_P |
| 1131 | |
| 1132 | setlocal list |
| 1133 | setlocal listchars=tab:>- |
| 1134 | setlocal linebreak |
| 1135 | setlocal nowrap |
| 1136 | setlocal filetype=help |
| 1137 | redraw! |
| 1138 | |
| 1139 | bwipe! |
| 1140 | endfunc |
| 1141 | |
zeertzjq | efabd7c | 2024-02-11 17:16:19 +0100 | [diff] [blame] | 1142 | func Test_breakindent_change_display_uhex() |
| 1143 | call s:test_windows('setl briopt=min:0 list listchars=eol:$') |
| 1144 | redraw! |
| 1145 | let lines = s:screen_lines(line('.'), 20) |
| 1146 | let expect = [ |
| 1147 | \ "^Iabcdefghijklmnopqr", |
| 1148 | \ " stuvwxyzABCDEFGHIJ", |
| 1149 | \ " KLMNOP$ " |
| 1150 | \ ] |
| 1151 | call s:compare_lines(expect, lines) |
| 1152 | set display+=uhex |
| 1153 | redraw! |
| 1154 | let lines = s:screen_lines(line('.'), 20) |
| 1155 | let expect = [ |
| 1156 | \ "<09>abcdefghijklmnop", |
| 1157 | \ " qrstuvwxyzABCDEF", |
| 1158 | \ " GHIJKLMNOP$ " |
| 1159 | \ ] |
| 1160 | call s:compare_lines(expect, lines) |
| 1161 | set display& |
| 1162 | |
| 1163 | call s:close_windows() |
| 1164 | endfunc |
| 1165 | |
| 1166 | func Test_breakindent_list_split() |
| 1167 | 10new |
| 1168 | 61vsplit |
| 1169 | setlocal tabstop=8 breakindent list listchars=tab:<->,eol:$ |
| 1170 | put =s:input |
| 1171 | 30vsplit |
| 1172 | setlocal listchars=eol:$ |
| 1173 | let expect = [ |
| 1174 | \ "^IabcdefghijklmnopqrstuvwxyzAB|<------>abcdefghijklmnopqrstuv", |
| 1175 | \ " CDEFGHIJKLMNOP$ | wxyzABCDEFGHIJKLMNOP$ ", |
| 1176 | \ "~ |~ " |
| 1177 | \ ] |
| 1178 | redraw! |
| 1179 | let lines = s:screen_lines(line('.'), 61) |
| 1180 | call s:compare_lines(expect, lines) |
| 1181 | wincmd p |
| 1182 | redraw! |
| 1183 | let lines = s:screen_lines(line('.'), 61) |
| 1184 | call s:compare_lines(expect, lines) |
| 1185 | |
| 1186 | bwipe! |
| 1187 | endfunc |
Bram Moolenaar | c67c89c | 2022-12-02 16:39:44 +0000 | [diff] [blame] | 1188 | |
zeertzjq | f0a9d65 | 2024-02-12 22:53:20 +0100 | [diff] [blame] | 1189 | func Test_breakindent_min_with_signcol() |
| 1190 | call s:test_windows('setl briopt=min:15 signcolumn=yes') |
| 1191 | redraw! |
| 1192 | let expect = [ |
| 1193 | \ " abcdefghijklmn", |
| 1194 | \ " opqrstuvwxyzABC", |
| 1195 | \ " DEFGHIJKLMNOP " |
| 1196 | \ ] |
| 1197 | let lines = s:screen_lines(line('.'), 20) |
| 1198 | call s:compare_lines(expect, lines) |
| 1199 | setl briopt=min:17 |
| 1200 | redraw! |
| 1201 | let expect = [ |
| 1202 | \ " abcdefghijklmn", |
| 1203 | \ " opqrstuvwxyzABCDE", |
| 1204 | \ " FGHIJKLMNOP " |
| 1205 | \ ] |
| 1206 | let lines = s:screen_lines(line('.'), 20) |
| 1207 | call s:compare_lines(expect, lines) |
| 1208 | setl briopt=min:19 |
| 1209 | redraw! |
| 1210 | let expect = [ |
| 1211 | \ " abcdefghijklmn", |
| 1212 | \ " opqrstuvwxyzABCDEF", |
| 1213 | \ " GHIJKLMNOP " |
| 1214 | \ ] |
| 1215 | let lines = s:screen_lines(line('.'), 20) |
| 1216 | call s:compare_lines(expect, lines) |
| 1217 | |
| 1218 | call s:close_windows() |
| 1219 | endfunc |
| 1220 | |
zeertzjq | b5d6b5c | 2024-07-18 21:13:31 +0200 | [diff] [blame] | 1221 | func Test_breakindent_with_double_width_wrap() |
| 1222 | 50vnew |
| 1223 | setlocal tabstop=8 breakindent nolist |
| 1224 | call setline(1, "\t" .. repeat('a', winwidth(0) - 9) .. '口口口') |
| 1225 | normal! $g0 |
| 1226 | call assert_equal(2, winline()) |
| 1227 | call assert_equal(9, wincol()) |
| 1228 | |
| 1229 | bwipe! |
| 1230 | endfunc |
| 1231 | |
Bram Moolenaar | 0e05de4 | 2020-03-25 22:23:46 +0100 | [diff] [blame] | 1232 | " vim: shiftwidth=2 sts=2 expandtab |