Bram Moolenaar | 98aefe7 | 2018-12-13 22:20:09 +0100 | [diff] [blame] | 1 | " Tests for defining text property types and adding text properties to the |
| 2 | " buffer. |
| 3 | |
| 4 | if !has('textprop') |
| 5 | finish |
| 6 | endif |
| 7 | |
Bram Moolenaar | c6d86dc | 2018-12-31 13:57:36 +0100 | [diff] [blame] | 8 | source screendump.vim |
| 9 | |
Bram Moolenaar | b9c67a5 | 2019-01-01 19:49:20 +0100 | [diff] [blame] | 10 | " test length zero |
| 11 | |
Bram Moolenaar | 98aefe7 | 2018-12-13 22:20:09 +0100 | [diff] [blame] | 12 | func Test_proptype_global() |
| 13 | call prop_type_add('comment', {'highlight': 'Directory', 'priority': 123, 'start_incl': 1, 'end_incl': 1}) |
| 14 | let proptypes = prop_type_list() |
| 15 | call assert_equal(1, len(proptypes)) |
| 16 | call assert_equal('comment', proptypes[0]) |
| 17 | |
| 18 | let proptype = prop_type_get('comment') |
| 19 | call assert_equal('Directory', proptype['highlight']) |
| 20 | call assert_equal(123, proptype['priority']) |
| 21 | call assert_equal(1, proptype['start_incl']) |
| 22 | call assert_equal(1, proptype['end_incl']) |
| 23 | |
| 24 | call prop_type_delete('comment') |
| 25 | call assert_equal(0, len(prop_type_list())) |
| 26 | |
| 27 | call prop_type_add('one', {}) |
| 28 | call assert_equal(1, len(prop_type_list())) |
| 29 | let proptype = prop_type_get('one') |
| 30 | call assert_false(has_key(proptype, 'highlight')) |
| 31 | call assert_equal(0, proptype['priority']) |
| 32 | call assert_equal(0, proptype['start_incl']) |
| 33 | call assert_equal(0, proptype['end_incl']) |
| 34 | |
| 35 | call prop_type_add('two', {}) |
| 36 | call assert_equal(2, len(prop_type_list())) |
| 37 | call prop_type_delete('one') |
| 38 | call assert_equal(1, len(prop_type_list())) |
| 39 | call prop_type_delete('two') |
| 40 | call assert_equal(0, len(prop_type_list())) |
| 41 | endfunc |
| 42 | |
| 43 | func Test_proptype_buf() |
| 44 | let bufnr = bufnr('') |
| 45 | call prop_type_add('comment', {'bufnr': bufnr, 'highlight': 'Directory', 'priority': 123, 'start_incl': 1, 'end_incl': 1}) |
| 46 | let proptypes = prop_type_list({'bufnr': bufnr}) |
| 47 | call assert_equal(1, len(proptypes)) |
| 48 | call assert_equal('comment', proptypes[0]) |
| 49 | |
| 50 | let proptype = prop_type_get('comment', {'bufnr': bufnr}) |
| 51 | call assert_equal('Directory', proptype['highlight']) |
| 52 | call assert_equal(123, proptype['priority']) |
| 53 | call assert_equal(1, proptype['start_incl']) |
| 54 | call assert_equal(1, proptype['end_incl']) |
| 55 | |
| 56 | call prop_type_delete('comment', {'bufnr': bufnr}) |
| 57 | call assert_equal(0, len(prop_type_list({'bufnr': bufnr}))) |
| 58 | |
| 59 | call prop_type_add('one', {'bufnr': bufnr}) |
| 60 | let proptype = prop_type_get('one', {'bufnr': bufnr}) |
| 61 | call assert_false(has_key(proptype, 'highlight')) |
| 62 | call assert_equal(0, proptype['priority']) |
| 63 | call assert_equal(0, proptype['start_incl']) |
| 64 | call assert_equal(0, proptype['end_incl']) |
| 65 | |
| 66 | call prop_type_add('two', {'bufnr': bufnr}) |
| 67 | call assert_equal(2, len(prop_type_list({'bufnr': bufnr}))) |
| 68 | call prop_type_delete('one', {'bufnr': bufnr}) |
| 69 | call assert_equal(1, len(prop_type_list({'bufnr': bufnr}))) |
| 70 | call prop_type_delete('two', {'bufnr': bufnr}) |
| 71 | call assert_equal(0, len(prop_type_list({'bufnr': bufnr}))) |
| 72 | endfunc |
| 73 | |
| 74 | func AddPropTypes() |
| 75 | call prop_type_add('one', {}) |
| 76 | call prop_type_add('two', {}) |
| 77 | call prop_type_add('three', {}) |
| 78 | call prop_type_add('whole', {}) |
| 79 | endfunc |
| 80 | |
| 81 | func DeletePropTypes() |
| 82 | call prop_type_delete('one') |
| 83 | call prop_type_delete('two') |
| 84 | call prop_type_delete('three') |
| 85 | call prop_type_delete('whole') |
| 86 | endfunc |
| 87 | |
| 88 | func SetupPropsInFirstLine() |
| 89 | call setline(1, 'one two three') |
| 90 | call prop_add(1, 1, {'length': 3, 'id': 11, 'type': 'one'}) |
| 91 | call prop_add(1, 5, {'length': 3, 'id': 12, 'type': 'two'}) |
| 92 | call prop_add(1, 8, {'length': 5, 'id': 13, 'type': 'three'}) |
| 93 | call prop_add(1, 1, {'length': 13, 'id': 14, 'type': 'whole'}) |
| 94 | endfunc |
| 95 | |
| 96 | let s:expected_props = [{'col': 1, 'length': 13, 'id': 14, 'type': 'whole', 'start': 1, 'end': 1}, |
| 97 | \ {'col': 1, 'length': 3, 'id': 11, 'type': 'one', 'start': 1, 'end': 1}, |
| 98 | \ {'col': 5, 'length': 3, 'id': 12, 'type': 'two', 'start': 1, 'end': 1}, |
| 99 | \ {'col': 8, 'length': 5, 'id': 13, 'type': 'three', 'start': 1, 'end': 1}, |
| 100 | \ ] |
| 101 | |
| 102 | func Test_prop_add() |
| 103 | new |
| 104 | call AddPropTypes() |
| 105 | call SetupPropsInFirstLine() |
| 106 | call assert_equal(s:expected_props, prop_list(1)) |
| 107 | call assert_fails("call prop_add(10, 1, {'length': 1, 'id': 14, 'type': 'whole'})", 'E966:') |
| 108 | call assert_fails("call prop_add(1, 22, {'length': 1, 'id': 14, 'type': 'whole'})", 'E964:') |
| 109 | |
| 110 | " Insert a line above, text props must still be there. |
| 111 | call append(0, 'empty') |
| 112 | call assert_equal(s:expected_props, prop_list(2)) |
| 113 | " Delete a line above, text props must still be there. |
| 114 | 1del |
| 115 | call assert_equal(s:expected_props, prop_list(1)) |
| 116 | |
Bram Moolenaar | b9c67a5 | 2019-01-01 19:49:20 +0100 | [diff] [blame] | 117 | " Prop without length or end column is zero length |
| 118 | call prop_clear(1) |
| 119 | call prop_add(1, 5, {'type': 'two'}) |
| 120 | let expected = [{'col': 5, 'length': 0, 'type': 'two', 'id': 0, 'start': 1, 'end': 1}] |
| 121 | call assert_equal(expected, prop_list(1)) |
| 122 | |
Bram Moolenaar | 98aefe7 | 2018-12-13 22:20:09 +0100 | [diff] [blame] | 123 | call DeletePropTypes() |
| 124 | bwipe! |
| 125 | endfunc |
| 126 | |
| 127 | func Test_prop_remove() |
| 128 | new |
| 129 | call AddPropTypes() |
| 130 | call SetupPropsInFirstLine() |
| 131 | let props = deepcopy(s:expected_props) |
| 132 | call assert_equal(props, prop_list(1)) |
| 133 | |
| 134 | " remove by id |
| 135 | call prop_remove({'id': 12}, 1) |
| 136 | unlet props[2] |
| 137 | call assert_equal(props, prop_list(1)) |
| 138 | |
| 139 | " remove by type |
| 140 | call prop_remove({'type': 'one'}, 1) |
| 141 | unlet props[1] |
| 142 | call assert_equal(props, prop_list(1)) |
| 143 | |
| 144 | call DeletePropTypes() |
| 145 | bwipe! |
| 146 | endfunc |
| 147 | |
Bram Moolenaar | 196d157 | 2019-01-02 23:47:18 +0100 | [diff] [blame] | 148 | func SetupOneLine() |
| 149 | call setline(1, 'xonex xtwoxx') |
| 150 | call AddPropTypes() |
| 151 | call prop_add(1, 2, {'length': 3, 'id': 11, 'type': 'one'}) |
| 152 | call prop_add(1, 8, {'length': 3, 'id': 12, 'type': 'two'}) |
| 153 | let expected = [ |
| 154 | \ {'col': 2, 'length': 3, 'id': 11, 'type': 'one', 'start': 1, 'end': 1}, |
| 155 | \ {'col': 8, 'length': 3, 'id': 12, 'type': 'two', 'start': 1, 'end': 1}, |
| 156 | \] |
| 157 | call assert_equal(expected, prop_list(1)) |
| 158 | return expected |
| 159 | endfunc |
| 160 | |
Bram Moolenaar | 98aefe7 | 2018-12-13 22:20:09 +0100 | [diff] [blame] | 161 | func Test_prop_add_remove_buf() |
| 162 | new |
| 163 | let bufnr = bufnr('') |
| 164 | call AddPropTypes() |
| 165 | call setline(1, 'one two three') |
| 166 | wincmd w |
| 167 | call prop_add(1, 1, {'length': 3, 'id': 11, 'type': 'one', 'bufnr': bufnr}) |
| 168 | call prop_add(1, 5, {'length': 3, 'id': 12, 'type': 'two', 'bufnr': bufnr}) |
| 169 | call prop_add(1, 11, {'length': 3, 'id': 13, 'type': 'three', 'bufnr': bufnr}) |
| 170 | |
| 171 | let props = [ |
| 172 | \ {'col': 1, 'length': 3, 'id': 11, 'type': 'one', 'start': 1, 'end': 1}, |
| 173 | \ {'col': 5, 'length': 3, 'id': 12, 'type': 'two', 'start': 1, 'end': 1}, |
| 174 | \ {'col': 11, 'length': 3, 'id': 13, 'type': 'three', 'start': 1, 'end': 1}, |
| 175 | \] |
| 176 | call assert_equal(props, prop_list(1, {'bufnr': bufnr})) |
| 177 | |
| 178 | " remove by id |
| 179 | call prop_remove({'id': 12, 'bufnr': bufnr}, 1) |
| 180 | unlet props[1] |
| 181 | call assert_equal(props, prop_list(1, {'bufnr': bufnr})) |
| 182 | |
| 183 | " remove by type |
| 184 | call prop_remove({'type': 'one', 'bufnr': bufnr}, 1) |
| 185 | unlet props[0] |
| 186 | call assert_equal(props, prop_list(1, {'bufnr': bufnr})) |
| 187 | |
| 188 | call DeletePropTypes() |
| 189 | wincmd w |
| 190 | bwipe! |
| 191 | endfunc |
| 192 | |
Bram Moolenaar | 33c8ca9 | 2019-01-02 18:00:27 +0100 | [diff] [blame] | 193 | func Test_prop_backspace() |
| 194 | new |
| 195 | set bs=2 |
Bram Moolenaar | 196d157 | 2019-01-02 23:47:18 +0100 | [diff] [blame] | 196 | let expected = SetupOneLine() " 'xonex xtwoxx' |
Bram Moolenaar | 33c8ca9 | 2019-01-02 18:00:27 +0100 | [diff] [blame] | 197 | |
| 198 | exe "normal 0li\<BS>\<Esc>fxli\<BS>\<Esc>" |
| 199 | call assert_equal('one xtwoxx', getline(1)) |
| 200 | let expected[0].col = 1 |
| 201 | let expected[1].col = 6 |
| 202 | call assert_equal(expected, prop_list(1)) |
| 203 | |
| 204 | call DeletePropTypes() |
| 205 | bwipe! |
| 206 | set bs& |
| 207 | endfunc |
Bram Moolenaar | 98aefe7 | 2018-12-13 22:20:09 +0100 | [diff] [blame] | 208 | |
Bram Moolenaar | 196d157 | 2019-01-02 23:47:18 +0100 | [diff] [blame] | 209 | func Test_prop_replace() |
| 210 | new |
| 211 | set bs=2 |
| 212 | let expected = SetupOneLine() " 'xonex xtwoxx' |
| 213 | |
| 214 | exe "normal 0Ryyy\<Esc>" |
| 215 | call assert_equal('yyyex xtwoxx', getline(1)) |
| 216 | call assert_equal(expected, prop_list(1)) |
| 217 | |
| 218 | exe "normal ftRyy\<BS>" |
| 219 | call assert_equal('yyyex xywoxx', getline(1)) |
| 220 | call assert_equal(expected, prop_list(1)) |
| 221 | |
| 222 | exe "normal 0fwRyy\<BS>" |
| 223 | call assert_equal('yyyex xyyoxx', getline(1)) |
| 224 | call assert_equal(expected, prop_list(1)) |
| 225 | |
| 226 | exe "normal 0foRyy\<BS>\<BS>" |
| 227 | call assert_equal('yyyex xyyoxx', getline(1)) |
| 228 | call assert_equal(expected, prop_list(1)) |
| 229 | |
| 230 | call DeletePropTypes() |
| 231 | bwipe! |
| 232 | set bs& |
| 233 | endfunc |
| 234 | |
Bram Moolenaar | 98aefe7 | 2018-12-13 22:20:09 +0100 | [diff] [blame] | 235 | func Test_prop_clear() |
| 236 | new |
| 237 | call AddPropTypes() |
| 238 | call SetupPropsInFirstLine() |
| 239 | call assert_equal(s:expected_props, prop_list(1)) |
| 240 | |
| 241 | call prop_clear(1) |
| 242 | call assert_equal([], prop_list(1)) |
| 243 | |
| 244 | call DeletePropTypes() |
| 245 | bwipe! |
| 246 | endfunc |
| 247 | |
| 248 | func Test_prop_clear_buf() |
| 249 | new |
| 250 | call AddPropTypes() |
| 251 | call SetupPropsInFirstLine() |
| 252 | let bufnr = bufnr('') |
| 253 | wincmd w |
| 254 | call assert_equal(s:expected_props, prop_list(1, {'bufnr': bufnr})) |
| 255 | |
| 256 | call prop_clear(1, 1, {'bufnr': bufnr}) |
| 257 | call assert_equal([], prop_list(1, {'bufnr': bufnr})) |
| 258 | |
| 259 | wincmd w |
| 260 | call DeletePropTypes() |
| 261 | bwipe! |
| 262 | endfunc |
| 263 | |
Bram Moolenaar | c1a9bc1 | 2018-12-28 21:59:29 +0100 | [diff] [blame] | 264 | " Setup a three line prop in lines 2 - 4. |
| 265 | " Add short props in line 1 and 5. |
| 266 | func Setup_three_line_prop() |
| 267 | new |
| 268 | call setline(1, ['one', 'twotwo', 'three', 'fourfour', 'five']) |
| 269 | call prop_add(1, 2, {'length': 1, 'type': 'comment'}) |
| 270 | call prop_add(2, 4, {'end_lnum': 4, 'end_col': 5, 'type': 'comment'}) |
| 271 | call prop_add(5, 2, {'length': 1, 'type': 'comment'}) |
| 272 | endfunc |
| 273 | |
Bram Moolenaar | e3d31b0 | 2018-12-24 23:07:04 +0100 | [diff] [blame] | 274 | func Test_prop_multiline() |
| 275 | call prop_type_add('comment', {'highlight': 'Directory'}) |
| 276 | new |
| 277 | call setline(1, ['xxxxxxx', 'yyyyyyyyy', 'zzzzzzzz']) |
| 278 | |
| 279 | " start halfway line 1, end halfway line 3 |
| 280 | call prop_add(1, 3, {'end_lnum': 3, 'end_col': 5, 'type': 'comment'}) |
| 281 | let expect1 = {'col': 3, 'length': 6, 'type': 'comment', 'start': 1, 'end': 0, 'id': 0} |
| 282 | call assert_equal([expect1], prop_list(1)) |
| 283 | let expect2 = {'col': 1, 'length': 10, 'type': 'comment', 'start': 0, 'end': 0, 'id': 0} |
| 284 | call assert_equal([expect2], prop_list(2)) |
Bram Moolenaar | b9c67a5 | 2019-01-01 19:49:20 +0100 | [diff] [blame] | 285 | let expect3 = {'col': 1, 'length': 4, 'type': 'comment', 'start': 0, 'end': 1, 'id': 0} |
Bram Moolenaar | e3d31b0 | 2018-12-24 23:07:04 +0100 | [diff] [blame] | 286 | call assert_equal([expect3], prop_list(3)) |
| 287 | call prop_clear(1, 3) |
| 288 | |
| 289 | " include all three lines |
| 290 | call prop_add(1, 1, {'end_lnum': 3, 'end_col': 999, 'type': 'comment'}) |
| 291 | let expect1.col = 1 |
| 292 | let expect1.length = 8 |
| 293 | call assert_equal([expect1], prop_list(1)) |
| 294 | call assert_equal([expect2], prop_list(2)) |
| 295 | let expect3.length = 9 |
| 296 | call assert_equal([expect3], prop_list(3)) |
| 297 | call prop_clear(1, 3) |
| 298 | |
| 299 | bwipe! |
Bram Moolenaar | c1a9bc1 | 2018-12-28 21:59:29 +0100 | [diff] [blame] | 300 | |
Bram Moolenaar | b9c67a5 | 2019-01-01 19:49:20 +0100 | [diff] [blame] | 301 | " Test deleting the first line of a multi-line prop. |
Bram Moolenaar | c1a9bc1 | 2018-12-28 21:59:29 +0100 | [diff] [blame] | 302 | call Setup_three_line_prop() |
Bram Moolenaar | b9c67a5 | 2019-01-01 19:49:20 +0100 | [diff] [blame] | 303 | let expect_short = {'col': 2, 'length': 1, 'type': 'comment', 'start': 1, 'end': 1, 'id': 0} |
| 304 | call assert_equal([expect_short], prop_list(1)) |
Bram Moolenaar | c1a9bc1 | 2018-12-28 21:59:29 +0100 | [diff] [blame] | 305 | let expect2 = {'col': 4, 'length': 4, 'type': 'comment', 'start': 1, 'end': 0, 'id': 0} |
| 306 | call assert_equal([expect2], prop_list(2)) |
| 307 | 2del |
Bram Moolenaar | c1a9bc1 | 2018-12-28 21:59:29 +0100 | [diff] [blame] | 308 | call assert_equal([expect_short], prop_list(1)) |
| 309 | let expect2 = {'col': 1, 'length': 6, 'type': 'comment', 'start': 1, 'end': 0, 'id': 0} |
| 310 | call assert_equal([expect2], prop_list(2)) |
| 311 | bwipe! |
| 312 | |
Bram Moolenaar | b9c67a5 | 2019-01-01 19:49:20 +0100 | [diff] [blame] | 313 | " Test deleting the last line of a multi-line prop. |
Bram Moolenaar | c1a9bc1 | 2018-12-28 21:59:29 +0100 | [diff] [blame] | 314 | call Setup_three_line_prop() |
| 315 | let expect3 = {'col': 1, 'length': 6, 'type': 'comment', 'start': 0, 'end': 0, 'id': 0} |
| 316 | call assert_equal([expect3], prop_list(3)) |
Bram Moolenaar | b9c67a5 | 2019-01-01 19:49:20 +0100 | [diff] [blame] | 317 | let expect4 = {'col': 1, 'length': 4, 'type': 'comment', 'start': 0, 'end': 1, 'id': 0} |
Bram Moolenaar | c1a9bc1 | 2018-12-28 21:59:29 +0100 | [diff] [blame] | 318 | call assert_equal([expect4], prop_list(4)) |
| 319 | 4del |
Bram Moolenaar | b9c67a5 | 2019-01-01 19:49:20 +0100 | [diff] [blame] | 320 | let expect3.end = 1 |
Bram Moolenaar | c1a9bc1 | 2018-12-28 21:59:29 +0100 | [diff] [blame] | 321 | call assert_equal([expect3], prop_list(3)) |
| 322 | call assert_equal([expect_short], prop_list(4)) |
| 323 | bwipe! |
| 324 | |
Bram Moolenaar | b9c67a5 | 2019-01-01 19:49:20 +0100 | [diff] [blame] | 325 | " Test appending a line below the multi-line text prop start. |
Bram Moolenaar | b56ac04 | 2018-12-28 23:22:40 +0100 | [diff] [blame] | 326 | call Setup_three_line_prop() |
| 327 | let expect2 = {'col': 4, 'length': 4, 'type': 'comment', 'start': 1, 'end': 0, 'id': 0} |
| 328 | call assert_equal([expect2], prop_list(2)) |
| 329 | call append(2, "new line") |
| 330 | call assert_equal([expect2], prop_list(2)) |
| 331 | let expect3 = {'col': 1, 'length': 9, 'type': 'comment', 'start': 0, 'end': 0, 'id': 0} |
| 332 | call assert_equal([expect3], prop_list(3)) |
| 333 | bwipe! |
| 334 | |
Bram Moolenaar | e3d31b0 | 2018-12-24 23:07:04 +0100 | [diff] [blame] | 335 | call prop_type_delete('comment') |
| 336 | endfunc |
| 337 | |
Bram Moolenaar | b413d2e | 2018-12-25 23:15:46 +0100 | [diff] [blame] | 338 | func Test_prop_byteoff() |
| 339 | call prop_type_add('comment', {'highlight': 'Directory'}) |
| 340 | new |
Bram Moolenaar | 00b1e04 | 2018-12-26 23:42:10 +0100 | [diff] [blame] | 341 | call setline(1, ['line1', 'second line', '']) |
Bram Moolenaar | 8cf734e | 2018-12-26 01:09:00 +0100 | [diff] [blame] | 342 | set ff=unix |
Bram Moolenaar | 00b1e04 | 2018-12-26 23:42:10 +0100 | [diff] [blame] | 343 | call assert_equal(19, line2byte(3)) |
Bram Moolenaar | b413d2e | 2018-12-25 23:15:46 +0100 | [diff] [blame] | 344 | call prop_add(1, 1, {'end_col': 3, 'type': 'comment'}) |
Bram Moolenaar | 00b1e04 | 2018-12-26 23:42:10 +0100 | [diff] [blame] | 345 | call assert_equal(19, line2byte(3)) |
Bram Moolenaar | b413d2e | 2018-12-25 23:15:46 +0100 | [diff] [blame] | 346 | |
| 347 | bwipe! |
| 348 | call prop_type_delete('comment') |
| 349 | endfunc |
| 350 | |
Bram Moolenaar | 7f1664e | 2019-01-04 17:21:24 +0100 | [diff] [blame^] | 351 | func Test_prop_undo() |
| 352 | new |
| 353 | call prop_type_add('comment', {'highlight': 'Directory'}) |
| 354 | call setline(1, ['oneone', 'twotwo', 'three']) |
| 355 | " Set 'undolevels' to break changes into undo-able pieces. |
| 356 | set ul& |
| 357 | |
| 358 | call prop_add(1, 3, {'end_col': 5, 'type': 'comment'}) |
| 359 | let expected = [{'col': 3, 'length': 2, 'id': 0, 'type': 'comment', 'start': 1, 'end': 1} ] |
| 360 | call assert_equal(expected, prop_list(1)) |
| 361 | |
| 362 | " Insert a character, then undo. |
| 363 | exe "normal 0lllix\<Esc>" |
| 364 | set ul& |
| 365 | let expected[0].length = 3 |
| 366 | call assert_equal(expected, prop_list(1)) |
| 367 | undo |
| 368 | let expected[0].length = 2 |
| 369 | call assert_equal(expected, prop_list(1)) |
| 370 | |
| 371 | " Delete a character, then undo |
| 372 | exe "normal 0lllx" |
| 373 | set ul& |
| 374 | let expected[0].length = 1 |
| 375 | call assert_equal(expected, prop_list(1)) |
| 376 | undo |
| 377 | let expected[0].length = 2 |
| 378 | call assert_equal(expected, prop_list(1)) |
| 379 | |
| 380 | " Delete the line, then undo |
| 381 | 1d |
| 382 | set ul& |
| 383 | call assert_equal([], prop_list(1)) |
| 384 | undo |
| 385 | call assert_equal(expected, prop_list(1)) |
| 386 | |
| 387 | " Insert a character, delete two characters, then undo with "U" |
| 388 | exe "normal 0lllix\<Esc>" |
| 389 | set ul& |
| 390 | let expected[0].length = 3 |
| 391 | call assert_equal(expected, prop_list(1)) |
| 392 | exe "normal 0lllxx" |
| 393 | set ul& |
| 394 | let expected[0].length = 1 |
| 395 | call assert_equal(expected, prop_list(1)) |
| 396 | normal U |
| 397 | let expected[0].length = 2 |
| 398 | call assert_equal(expected, prop_list(1)) |
| 399 | |
| 400 | bwipe! |
| 401 | call prop_type_delete('comment') |
| 402 | endfunc |
| 403 | |
Bram Moolenaar | c6d86dc | 2018-12-31 13:57:36 +0100 | [diff] [blame] | 404 | " screenshot test with textprop highlighting |
| 405 | funct Test_textprop_screenshots() |
Bram Moolenaar | b9c67a5 | 2019-01-01 19:49:20 +0100 | [diff] [blame] | 406 | if !CanRunVimInTerminal() || &encoding != 'utf-8' |
Bram Moolenaar | c6d86dc | 2018-12-31 13:57:36 +0100 | [diff] [blame] | 407 | return |
| 408 | endif |
| 409 | call writefile([ |
Bram Moolenaar | 44746aa | 2019-01-02 00:02:11 +0100 | [diff] [blame] | 410 | \ "call setline(1, ['One two', 'Numbér 123 änd thœn 4¾7.', '--aa--bb--cc--dd--'])", |
Bram Moolenaar | c6d86dc | 2018-12-31 13:57:36 +0100 | [diff] [blame] | 411 | \ "hi NumberProp ctermfg=blue", |
| 412 | \ "hi LongProp ctermbg=yellow", |
| 413 | \ "call prop_type_add('number', {'highlight': 'NumberProp'})", |
| 414 | \ "call prop_type_add('long', {'highlight': 'LongProp'})", |
Bram Moolenaar | 44746aa | 2019-01-02 00:02:11 +0100 | [diff] [blame] | 415 | \ "call prop_type_add('start', {'highlight': 'NumberProp', 'start_incl': 1})", |
| 416 | \ "call prop_type_add('end', {'highlight': 'NumberProp', 'end_incl': 1})", |
| 417 | \ "call prop_type_add('both', {'highlight': 'NumberProp', 'start_incl': 1, 'end_incl': 1})", |
Bram Moolenaar | c6d86dc | 2018-12-31 13:57:36 +0100 | [diff] [blame] | 418 | \ "call prop_add(1, 4, {'end_lnum': 3, 'end_col': 3, 'type': 'long'})", |
Bram Moolenaar | b9c67a5 | 2019-01-01 19:49:20 +0100 | [diff] [blame] | 419 | \ "call prop_add(2, 9, {'length': 3, 'type': 'number'})", |
| 420 | \ "call prop_add(2, 24, {'length': 4, 'type': 'number'})", |
Bram Moolenaar | 44746aa | 2019-01-02 00:02:11 +0100 | [diff] [blame] | 421 | \ "call prop_add(3, 3, {'length': 2, 'type': 'number'})", |
| 422 | \ "call prop_add(3, 7, {'length': 2, 'type': 'start'})", |
| 423 | \ "call prop_add(3, 11, {'length': 2, 'type': 'end'})", |
| 424 | \ "call prop_add(3, 15, {'length': 2, 'type': 'both'})", |
Bram Moolenaar | c6d86dc | 2018-12-31 13:57:36 +0100 | [diff] [blame] | 425 | \ "set number", |
Bram Moolenaar | b9c67a5 | 2019-01-01 19:49:20 +0100 | [diff] [blame] | 426 | \ "hi clear SpellBad", |
Bram Moolenaar | c6d86dc | 2018-12-31 13:57:36 +0100 | [diff] [blame] | 427 | \ "set spell", |
Bram Moolenaar | 44746aa | 2019-01-02 00:02:11 +0100 | [diff] [blame] | 428 | \ "normal 3G0llix\<Esc>lllix\<Esc>lllix\<Esc>lllix\<Esc>lllix\<Esc>lllix\<Esc>lllix\<Esc>lllix\<Esc>", |
Bram Moolenaar | 33c8ca9 | 2019-01-02 18:00:27 +0100 | [diff] [blame] | 429 | \ "normal 3G0lli\<BS>\<Esc>", |
Bram Moolenaar | c6d86dc | 2018-12-31 13:57:36 +0100 | [diff] [blame] | 430 | \], 'XtestProp') |
Bram Moolenaar | b9c67a5 | 2019-01-01 19:49:20 +0100 | [diff] [blame] | 431 | let buf = RunVimInTerminal('-S XtestProp', {'rows': 6}) |
Bram Moolenaar | c6d86dc | 2018-12-31 13:57:36 +0100 | [diff] [blame] | 432 | call VerifyScreenDump(buf, 'Test_textprop_01', {}) |
Bram Moolenaar | e3d31b0 | 2018-12-24 23:07:04 +0100 | [diff] [blame] | 433 | |
Bram Moolenaar | c6d86dc | 2018-12-31 13:57:36 +0100 | [diff] [blame] | 434 | " clean up |
| 435 | call StopVimInTerminal(buf) |
Bram Moolenaar | 2f21fa8 | 2018-12-31 20:05:56 +0100 | [diff] [blame] | 436 | call delete('XtestProp') |
Bram Moolenaar | c6d86dc | 2018-12-31 13:57:36 +0100 | [diff] [blame] | 437 | endfunc |