Mercurial > vim
comparison src/testdir/test_textprop.vim @ 25640:78ef12e0ce8c v8.2.3356
patch 8.2.3356: adding many text properties requires a lot of function calls
Commit: https://github.com/vim/vim/commit/ccfb7c6758510e0fe5f390149ea14aee6ff4f55e
Author: Yegappan Lakshmanan <yegappan@yahoo.com>
Date: Mon Aug 16 21:39:09 2021 +0200
patch 8.2.3356: adding many text properties requires a lot of function calls
Problem: Adding many text properties requires a lot of function calls.
Solution: Add the prop_add_list() function. (Yegappan Lakshmanan,
closes #8751)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Mon, 16 Aug 2021 21:45:03 +0200 |
parents | 0407a3db3ef6 |
children | ab42c36d1a27 |
comparison
equal
deleted
inserted
replaced
25639:b5eedbdaca91 | 25640:78ef12e0ce8c |
---|---|
335 call assert_fails("call prop_add(1, 5, {'type': 'two', 'bufnr': 234343})", 'E158:') | 335 call assert_fails("call prop_add(1, 5, {'type': 'two', 'bufnr': 234343})", 'E158:') |
336 | 336 |
337 call DeletePropTypes() | 337 call DeletePropTypes() |
338 call prop_type_delete('included') | 338 call prop_type_delete('included') |
339 bwipe! | 339 bwipe! |
340 endfunc | |
341 | |
342 " Test for the prop_add_list() function | |
343 func Test_prop_add_list() | |
344 new | |
345 call AddPropTypes() | |
346 call setline(1, ['one one one', 'two two two', 'six six six', 'ten ten ten']) | |
347 call prop_add_list(#{type: 'one', id: 2}, | |
348 \ [[1, 1, 1, 3], [2, 5, 2, 7], [3, 6, 4, 6]]) | |
349 call assert_equal([#{id: 2, col: 1, type_bufnr: 0, end: 1, type: 'one', | |
350 \ length: 2, start: 1}], prop_list(1)) | |
351 call assert_equal([#{id: 2, col: 5, type_bufnr: 0, end: 1, type: 'one', | |
352 \ length: 2, start: 1}], prop_list(2)) | |
353 call assert_equal([#{id: 2, col: 6, type_bufnr: 0, end: 0, type: 'one', | |
354 \ length: 7, start: 1}], prop_list(3)) | |
355 call assert_equal([#{id: 2, col: 1, type_bufnr: 0, end: 1, type: 'one', | |
356 \ length: 5, start: 0}], prop_list(4)) | |
357 call assert_fails('call prop_add_list([1, 2], [[1, 1, 3]])', 'E1206:') | |
358 call assert_fails('call prop_add_list({}, {})', 'E1211:') | |
359 call assert_fails('call prop_add_list({}, [[1, 1, 3]])', 'E965:') | |
360 call assert_fails('call prop_add_list(#{type: "abc"}, [[1, 1, 1, 3]])', 'E971:') | |
361 call assert_fails('call prop_add_list(#{type: "one"}, [[]])', 'E474:') | |
362 call assert_fails('call prop_add_list(#{type: "one"}, [[1, 1, 1, 1], {}])', 'E714:') | |
363 call assert_fails('call prop_add_list(#{type: "one"}, [[1, 1, "a"]])', 'E474:') | |
364 call assert_fails('call prop_add_list(#{type: "one"}, [[2, 2]])', 'E474:') | |
365 call assert_fails('call prop_add_list(#{type: "one"}, [[1, 1, 2], [2, 2]])', 'E474:') | |
366 call assert_fails('call prop_add_list(#{type: "one"}, [[1, 1, 1, 2], [4, 1, 5, 2]])', 'E966:') | |
367 call assert_fails('call prop_add_list(#{type: "one"}, [[3, 1, 1, 2]])', 'E966:') | |
368 call assert_fails('call prop_add_list(#{type: "one"}, [[2, 2, 2, 2], [3, 20, 3, 22]])', 'E964:') | |
369 call assert_fails('eval #{type: "one"}->prop_add_list([[2, 2, 2, 2], [3, 20, 3, 22]])', 'E964:') | |
370 call assert_fails('call prop_add_list(test_null_dict(), [[2, 2, 2]])', 'E965:') | |
371 call assert_fails('call prop_add_list(#{type: "one"}, test_null_list())', 'E714:') | |
372 call assert_fails('call prop_add_list(#{type: "one"}, [test_null_list()])', 'E714:') | |
373 call DeletePropTypes() | |
374 bw! | |
340 endfunc | 375 endfunc |
341 | 376 |
342 func Test_prop_remove() | 377 func Test_prop_remove() |
343 new | 378 new |
344 call AddPropTypes() | 379 call AddPropTypes() |