annotate src/testdir/test_textprop.vim @ 18444:967ca19425e3 v8.1.2216

patch 8.1.2216: text property in wrong place after :substitute Commit: https://github.com/vim/vim/commit/1fd30d7bae1b3e57f008c052d765a3ec73d58114 Author: Bram Moolenaar <Bram@vim.org> Date: Fri Oct 25 22:13:29 2019 +0200 patch 8.1.2216: text property in wrong place after :substitute Problem: Text property in wrong place after :substitute. Solution: Pass the new column instead of the old one. (Christian Brabandt, closes #4427)
author Bram Moolenaar <Bram@vim.org>
date Fri, 25 Oct 2019 22:15:03 +0200
parents d2228d4cf1f6
children 0ac88fdbf089
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
15138
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1 " Tests for defining text property types and adding text properties to the
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2 " buffer.
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3
17089
8e9e9124c7a2 patch 8.1.1544: some balloon tests don't run when they can
Bram Moolenaar <Bram@vim.org>
parents: 17049
diff changeset
4 source check.vim
8e9e9124c7a2 patch 8.1.1544: some balloon tests don't run when they can
Bram Moolenaar <Bram@vim.org>
parents: 17049
diff changeset
5 CheckFeature textprop
15138
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
6
15314
c4d62945d96f patch 8.1.0665: text property display wrong when 'spell' is set
Bram Moolenaar <Bram@vim.org>
parents: 15294
diff changeset
7 source screendump.vim
c4d62945d96f patch 8.1.0665: text property display wrong when 'spell' is set
Bram Moolenaar <Bram@vim.org>
parents: 15294
diff changeset
8
15335
18c20ceee4b5 patch 8.1.0675: text property column in screen columns is not practical
Bram Moolenaar <Bram@vim.org>
parents: 15318
diff changeset
9 " test length zero
18c20ceee4b5 patch 8.1.0675: text property column in screen columns is not practical
Bram Moolenaar <Bram@vim.org>
parents: 15318
diff changeset
10
15138
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
11 func Test_proptype_global()
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
12 call prop_type_add('comment', {'highlight': 'Directory', 'priority': 123, 'start_incl': 1, 'end_incl': 1})
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
13 let proptypes = prop_type_list()
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
14 call assert_equal(1, len(proptypes))
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
15 call assert_equal('comment', proptypes[0])
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
16
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
17 let proptype = prop_type_get('comment')
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
18 call assert_equal('Directory', proptype['highlight'])
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
19 call assert_equal(123, proptype['priority'])
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
20 call assert_equal(1, proptype['start_incl'])
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
21 call assert_equal(1, proptype['end_incl'])
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
22
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
23 call prop_type_delete('comment')
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
24 call assert_equal(0, len(prop_type_list()))
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
25
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
26 call prop_type_add('one', {})
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
27 call assert_equal(1, len(prop_type_list()))
17980
52f23198af7f patch 8.1.1986: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17694
diff changeset
28 let proptype = 'one'->prop_type_get()
15138
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
29 call assert_false(has_key(proptype, 'highlight'))
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
30 call assert_equal(0, proptype['priority'])
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
31 call assert_equal(0, proptype['start_incl'])
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
32 call assert_equal(0, proptype['end_incl'])
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
33
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
34 call prop_type_add('two', {})
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
35 call assert_equal(2, len(prop_type_list()))
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
36 call prop_type_delete('one')
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
37 call assert_equal(1, len(prop_type_list()))
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
38 call prop_type_delete('two')
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
39 call assert_equal(0, len(prop_type_list()))
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
40 endfunc
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
41
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
42 func Test_proptype_buf()
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
43 let bufnr = bufnr('')
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
44 call prop_type_add('comment', {'bufnr': bufnr, 'highlight': 'Directory', 'priority': 123, 'start_incl': 1, 'end_incl': 1})
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
45 let proptypes = prop_type_list({'bufnr': bufnr})
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
46 call assert_equal(1, len(proptypes))
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
47 call assert_equal('comment', proptypes[0])
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
48
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
49 let proptype = prop_type_get('comment', {'bufnr': bufnr})
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
50 call assert_equal('Directory', proptype['highlight'])
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
51 call assert_equal(123, proptype['priority'])
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
52 call assert_equal(1, proptype['start_incl'])
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
53 call assert_equal(1, proptype['end_incl'])
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
54
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
55 call prop_type_delete('comment', {'bufnr': bufnr})
17980
52f23198af7f patch 8.1.1986: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17694
diff changeset
56 call assert_equal(0, len({'bufnr': bufnr}->prop_type_list()))
15138
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
57
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
58 call prop_type_add('one', {'bufnr': bufnr})
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
59 let proptype = prop_type_get('one', {'bufnr': bufnr})
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
60 call assert_false(has_key(proptype, 'highlight'))
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
61 call assert_equal(0, proptype['priority'])
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
62 call assert_equal(0, proptype['start_incl'])
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
63 call assert_equal(0, proptype['end_incl'])
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
64
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
65 call prop_type_add('two', {'bufnr': bufnr})
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
66 call assert_equal(2, len(prop_type_list({'bufnr': bufnr})))
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
67 call prop_type_delete('one', {'bufnr': bufnr})
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
68 call assert_equal(1, len(prop_type_list({'bufnr': bufnr})))
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
69 call prop_type_delete('two', {'bufnr': bufnr})
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
70 call assert_equal(0, len(prop_type_list({'bufnr': bufnr})))
16772
18093a6accb5 patch 8.1.1388: errors when calling prop_remove() for an unloaded buffer
Bram Moolenaar <Bram@vim.org>
parents: 16770
diff changeset
71
18093a6accb5 patch 8.1.1388: errors when calling prop_remove() for an unloaded buffer
Bram Moolenaar <Bram@vim.org>
parents: 16770
diff changeset
72 call assert_fails("call prop_type_add('one', {'bufnr': 98764})", "E158:")
15138
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
73 endfunc
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
74
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
75 func AddPropTypes()
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
76 call prop_type_add('one', {})
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
77 call prop_type_add('two', {})
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
78 call prop_type_add('three', {})
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
79 call prop_type_add('whole', {})
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
80 endfunc
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
81
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
82 func DeletePropTypes()
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
83 call prop_type_delete('one')
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
84 call prop_type_delete('two')
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
85 call prop_type_delete('three')
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
86 call prop_type_delete('whole')
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
87 endfunc
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
88
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
89 func SetupPropsInFirstLine()
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
90 call setline(1, 'one two three')
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
91 call prop_add(1, 1, {'length': 3, 'id': 11, 'type': 'one'})
17980
52f23198af7f patch 8.1.1986: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17694
diff changeset
92 eval 1->prop_add(5, {'length': 3, 'id': 12, 'type': 'two'})
15367
273649cad196 patch 8.1.0691: text properties are not adjusted for :substitute
Bram Moolenaar <Bram@vim.org>
parents: 15365
diff changeset
93 call prop_add(1, 9, {'length': 5, 'id': 13, 'type': 'three'})
15138
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
94 call prop_add(1, 1, {'length': 13, 'id': 14, 'type': 'whole'})
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
95 endfunc
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
96
15367
273649cad196 patch 8.1.0691: text properties are not adjusted for :substitute
Bram Moolenaar <Bram@vim.org>
parents: 15365
diff changeset
97 func Get_expected_props()
273649cad196 patch 8.1.0691: text properties are not adjusted for :substitute
Bram Moolenaar <Bram@vim.org>
parents: 15365
diff changeset
98 return [
273649cad196 patch 8.1.0691: text properties are not adjusted for :substitute
Bram Moolenaar <Bram@vim.org>
parents: 15365
diff changeset
99 \ {'col': 1, 'length': 13, 'id': 14, 'type': 'whole', 'start': 1, 'end': 1},
15138
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
100 \ {'col': 1, 'length': 3, 'id': 11, 'type': 'one', 'start': 1, 'end': 1},
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
101 \ {'col': 5, 'length': 3, 'id': 12, 'type': 'two', 'start': 1, 'end': 1},
15367
273649cad196 patch 8.1.0691: text properties are not adjusted for :substitute
Bram Moolenaar <Bram@vim.org>
parents: 15365
diff changeset
102 \ {'col': 9, 'length': 5, 'id': 13, 'type': 'three', 'start': 1, 'end': 1},
15138
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
103 \ ]
15367
273649cad196 patch 8.1.0691: text properties are not adjusted for :substitute
Bram Moolenaar <Bram@vim.org>
parents: 15365
diff changeset
104 endfunc
15138
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
105
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
106 func Test_prop_add()
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
107 new
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
108 call AddPropTypes()
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
109 call SetupPropsInFirstLine()
15367
273649cad196 patch 8.1.0691: text properties are not adjusted for :substitute
Bram Moolenaar <Bram@vim.org>
parents: 15365
diff changeset
110 let expected_props = Get_expected_props()
273649cad196 patch 8.1.0691: text properties are not adjusted for :substitute
Bram Moolenaar <Bram@vim.org>
parents: 15365
diff changeset
111 call assert_equal(expected_props, prop_list(1))
15138
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
112 call assert_fails("call prop_add(10, 1, {'length': 1, 'id': 14, 'type': 'whole'})", 'E966:')
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
113 call assert_fails("call prop_add(1, 22, {'length': 1, 'id': 14, 'type': 'whole'})", 'E964:')
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
114
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
115 " Insert a line above, text props must still be there.
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
116 call append(0, 'empty')
15367
273649cad196 patch 8.1.0691: text properties are not adjusted for :substitute
Bram Moolenaar <Bram@vim.org>
parents: 15365
diff changeset
117 call assert_equal(expected_props, prop_list(2))
15138
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
118 " Delete a line above, text props must still be there.
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
119 1del
15367
273649cad196 patch 8.1.0691: text properties are not adjusted for :substitute
Bram Moolenaar <Bram@vim.org>
parents: 15365
diff changeset
120 call assert_equal(expected_props, prop_list(1))
15138
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
121
15335
18c20ceee4b5 patch 8.1.0675: text property column in screen columns is not practical
Bram Moolenaar <Bram@vim.org>
parents: 15318
diff changeset
122 " Prop without length or end column is zero length
18c20ceee4b5 patch 8.1.0675: text property column in screen columns is not practical
Bram Moolenaar <Bram@vim.org>
parents: 15318
diff changeset
123 call prop_clear(1)
18c20ceee4b5 patch 8.1.0675: text property column in screen columns is not practical
Bram Moolenaar <Bram@vim.org>
parents: 15318
diff changeset
124 call prop_add(1, 5, {'type': 'two'})
18c20ceee4b5 patch 8.1.0675: text property column in screen columns is not practical
Bram Moolenaar <Bram@vim.org>
parents: 15318
diff changeset
125 let expected = [{'col': 5, 'length': 0, 'type': 'two', 'id': 0, 'start': 1, 'end': 1}]
18c20ceee4b5 patch 8.1.0675: text property column in screen columns is not practical
Bram Moolenaar <Bram@vim.org>
parents: 15318
diff changeset
126 call assert_equal(expected, prop_list(1))
18c20ceee4b5 patch 8.1.0675: text property column in screen columns is not practical
Bram Moolenaar <Bram@vim.org>
parents: 15318
diff changeset
127
16772
18093a6accb5 patch 8.1.1388: errors when calling prop_remove() for an unloaded buffer
Bram Moolenaar <Bram@vim.org>
parents: 16770
diff changeset
128 call assert_fails("call prop_add(1, 5, {'type': 'two', 'bufnr': 234343})", 'E158:')
18093a6accb5 patch 8.1.1388: errors when calling prop_remove() for an unloaded buffer
Bram Moolenaar <Bram@vim.org>
parents: 16770
diff changeset
129
15138
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
130 call DeletePropTypes()
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
131 bwipe!
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
132 endfunc
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
133
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
134 func Test_prop_remove()
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
135 new
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
136 call AddPropTypes()
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
137 call SetupPropsInFirstLine()
15367
273649cad196 patch 8.1.0691: text properties are not adjusted for :substitute
Bram Moolenaar <Bram@vim.org>
parents: 15365
diff changeset
138 let props = Get_expected_props()
15138
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
139 call assert_equal(props, prop_list(1))
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
140
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
141 " remove by id
17980
52f23198af7f patch 8.1.1986: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17694
diff changeset
142 call assert_equal(1, {'id': 12}->prop_remove(1))
15138
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
143 unlet props[2]
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
144 call assert_equal(props, prop_list(1))
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
145
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
146 " remove by type
16772
18093a6accb5 patch 8.1.1388: errors when calling prop_remove() for an unloaded buffer
Bram Moolenaar <Bram@vim.org>
parents: 16770
diff changeset
147 call assert_equal(1, prop_remove({'type': 'one'}, 1))
15138
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
148 unlet props[1]
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
149 call assert_equal(props, prop_list(1))
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
150
16772
18093a6accb5 patch 8.1.1388: errors when calling prop_remove() for an unloaded buffer
Bram Moolenaar <Bram@vim.org>
parents: 16770
diff changeset
151 " remove from unknown buffer
18093a6accb5 patch 8.1.1388: errors when calling prop_remove() for an unloaded buffer
Bram Moolenaar <Bram@vim.org>
parents: 16770
diff changeset
152 call assert_fails("call prop_remove({'type': 'one', 'bufnr': 123456}, 1)", 'E158:')
18093a6accb5 patch 8.1.1388: errors when calling prop_remove() for an unloaded buffer
Bram Moolenaar <Bram@vim.org>
parents: 16770
diff changeset
153
15138
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
154 call DeletePropTypes()
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
155 bwipe!
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
156 endfunc
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
157
15349
6abee072b93c patch 8.1.0682: text properties not adjusted when backspacing replaced text
Bram Moolenaar <Bram@vim.org>
parents: 15347
diff changeset
158 func SetupOneLine()
6abee072b93c patch 8.1.0682: text properties not adjusted when backspacing replaced text
Bram Moolenaar <Bram@vim.org>
parents: 15347
diff changeset
159 call setline(1, 'xonex xtwoxx')
16662
1fc9cd08cf3c patch 8.1.1333: text properties don't always move after changes
Bram Moolenaar <Bram@vim.org>
parents: 16545
diff changeset
160 normal gg0
15349
6abee072b93c patch 8.1.0682: text properties not adjusted when backspacing replaced text
Bram Moolenaar <Bram@vim.org>
parents: 15347
diff changeset
161 call AddPropTypes()
6abee072b93c patch 8.1.0682: text properties not adjusted when backspacing replaced text
Bram Moolenaar <Bram@vim.org>
parents: 15347
diff changeset
162 call prop_add(1, 2, {'length': 3, 'id': 11, 'type': 'one'})
6abee072b93c patch 8.1.0682: text properties not adjusted when backspacing replaced text
Bram Moolenaar <Bram@vim.org>
parents: 15347
diff changeset
163 call prop_add(1, 8, {'length': 3, 'id': 12, 'type': 'two'})
6abee072b93c patch 8.1.0682: text properties not adjusted when backspacing replaced text
Bram Moolenaar <Bram@vim.org>
parents: 15347
diff changeset
164 let expected = [
6abee072b93c patch 8.1.0682: text properties not adjusted when backspacing replaced text
Bram Moolenaar <Bram@vim.org>
parents: 15347
diff changeset
165 \ {'col': 2, 'length': 3, 'id': 11, 'type': 'one', 'start': 1, 'end': 1},
6abee072b93c patch 8.1.0682: text properties not adjusted when backspacing replaced text
Bram Moolenaar <Bram@vim.org>
parents: 15347
diff changeset
166 \ {'col': 8, 'length': 3, 'id': 12, 'type': 'two', 'start': 1, 'end': 1},
6abee072b93c patch 8.1.0682: text properties not adjusted when backspacing replaced text
Bram Moolenaar <Bram@vim.org>
parents: 15347
diff changeset
167 \]
6abee072b93c patch 8.1.0682: text properties not adjusted when backspacing replaced text
Bram Moolenaar <Bram@vim.org>
parents: 15347
diff changeset
168 call assert_equal(expected, prop_list(1))
6abee072b93c patch 8.1.0682: text properties not adjusted when backspacing replaced text
Bram Moolenaar <Bram@vim.org>
parents: 15347
diff changeset
169 return expected
6abee072b93c patch 8.1.0682: text properties not adjusted when backspacing replaced text
Bram Moolenaar <Bram@vim.org>
parents: 15347
diff changeset
170 endfunc
6abee072b93c patch 8.1.0682: text properties not adjusted when backspacing replaced text
Bram Moolenaar <Bram@vim.org>
parents: 15347
diff changeset
171
15138
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
172 func Test_prop_add_remove_buf()
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
173 new
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
174 let bufnr = bufnr('')
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
175 call AddPropTypes()
16060
176872829dc2 patch 8.1.1035: prop_remove() second argument is not optional
Bram Moolenaar <Bram@vim.org>
parents: 15928
diff changeset
176 for lnum in range(1, 4)
176872829dc2 patch 8.1.1035: prop_remove() second argument is not optional
Bram Moolenaar <Bram@vim.org>
parents: 15928
diff changeset
177 call setline(lnum, 'one two three')
176872829dc2 patch 8.1.1035: prop_remove() second argument is not optional
Bram Moolenaar <Bram@vim.org>
parents: 15928
diff changeset
178 endfor
15138
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
179 wincmd w
16060
176872829dc2 patch 8.1.1035: prop_remove() second argument is not optional
Bram Moolenaar <Bram@vim.org>
parents: 15928
diff changeset
180 for lnum in range(1, 4)
176872829dc2 patch 8.1.1035: prop_remove() second argument is not optional
Bram Moolenaar <Bram@vim.org>
parents: 15928
diff changeset
181 call prop_add(lnum, 1, {'length': 3, 'id': 11, 'type': 'one', 'bufnr': bufnr})
176872829dc2 patch 8.1.1035: prop_remove() second argument is not optional
Bram Moolenaar <Bram@vim.org>
parents: 15928
diff changeset
182 call prop_add(lnum, 5, {'length': 3, 'id': 12, 'type': 'two', 'bufnr': bufnr})
176872829dc2 patch 8.1.1035: prop_remove() second argument is not optional
Bram Moolenaar <Bram@vim.org>
parents: 15928
diff changeset
183 call prop_add(lnum, 11, {'length': 3, 'id': 13, 'type': 'three', 'bufnr': bufnr})
176872829dc2 patch 8.1.1035: prop_remove() second argument is not optional
Bram Moolenaar <Bram@vim.org>
parents: 15928
diff changeset
184 endfor
176872829dc2 patch 8.1.1035: prop_remove() second argument is not optional
Bram Moolenaar <Bram@vim.org>
parents: 15928
diff changeset
185
15138
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
186 let props = [
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
187 \ {'col': 1, 'length': 3, 'id': 11, 'type': 'one', 'start': 1, 'end': 1},
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
188 \ {'col': 5, 'length': 3, 'id': 12, 'type': 'two', 'start': 1, 'end': 1},
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
189 \ {'col': 11, 'length': 3, 'id': 13, 'type': 'three', 'start': 1, 'end': 1},
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
190 \]
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
191 call assert_equal(props, prop_list(1, {'bufnr': bufnr}))
16060
176872829dc2 patch 8.1.1035: prop_remove() second argument is not optional
Bram Moolenaar <Bram@vim.org>
parents: 15928
diff changeset
192
15138
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
193 " remove by id
16060
176872829dc2 patch 8.1.1035: prop_remove() second argument is not optional
Bram Moolenaar <Bram@vim.org>
parents: 15928
diff changeset
194 let before_props = deepcopy(props)
176872829dc2 patch 8.1.1035: prop_remove() second argument is not optional
Bram Moolenaar <Bram@vim.org>
parents: 15928
diff changeset
195 unlet props[1]
176872829dc2 patch 8.1.1035: prop_remove() second argument is not optional
Bram Moolenaar <Bram@vim.org>
parents: 15928
diff changeset
196
15138
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
197 call prop_remove({'id': 12, 'bufnr': bufnr}, 1)
16060
176872829dc2 patch 8.1.1035: prop_remove() second argument is not optional
Bram Moolenaar <Bram@vim.org>
parents: 15928
diff changeset
198 call assert_equal(props, prop_list(1, {'bufnr': bufnr}))
176872829dc2 patch 8.1.1035: prop_remove() second argument is not optional
Bram Moolenaar <Bram@vim.org>
parents: 15928
diff changeset
199 call assert_equal(before_props, prop_list(2, {'bufnr': bufnr}))
176872829dc2 patch 8.1.1035: prop_remove() second argument is not optional
Bram Moolenaar <Bram@vim.org>
parents: 15928
diff changeset
200 call assert_equal(before_props, prop_list(3, {'bufnr': bufnr}))
176872829dc2 patch 8.1.1035: prop_remove() second argument is not optional
Bram Moolenaar <Bram@vim.org>
parents: 15928
diff changeset
201 call assert_equal(before_props, prop_list(4, {'bufnr': bufnr}))
176872829dc2 patch 8.1.1035: prop_remove() second argument is not optional
Bram Moolenaar <Bram@vim.org>
parents: 15928
diff changeset
202
176872829dc2 patch 8.1.1035: prop_remove() second argument is not optional
Bram Moolenaar <Bram@vim.org>
parents: 15928
diff changeset
203 call prop_remove({'id': 12, 'bufnr': bufnr}, 3, 4)
15138
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
204 call assert_equal(props, prop_list(1, {'bufnr': bufnr}))
16060
176872829dc2 patch 8.1.1035: prop_remove() second argument is not optional
Bram Moolenaar <Bram@vim.org>
parents: 15928
diff changeset
205 call assert_equal(before_props, prop_list(2, {'bufnr': bufnr}))
176872829dc2 patch 8.1.1035: prop_remove() second argument is not optional
Bram Moolenaar <Bram@vim.org>
parents: 15928
diff changeset
206 call assert_equal(props, prop_list(3, {'bufnr': bufnr}))
176872829dc2 patch 8.1.1035: prop_remove() second argument is not optional
Bram Moolenaar <Bram@vim.org>
parents: 15928
diff changeset
207 call assert_equal(props, prop_list(4, {'bufnr': bufnr}))
176872829dc2 patch 8.1.1035: prop_remove() second argument is not optional
Bram Moolenaar <Bram@vim.org>
parents: 15928
diff changeset
208
176872829dc2 patch 8.1.1035: prop_remove() second argument is not optional
Bram Moolenaar <Bram@vim.org>
parents: 15928
diff changeset
209 call prop_remove({'id': 12, 'bufnr': bufnr})
176872829dc2 patch 8.1.1035: prop_remove() second argument is not optional
Bram Moolenaar <Bram@vim.org>
parents: 15928
diff changeset
210 for lnum in range(1, 4)
176872829dc2 patch 8.1.1035: prop_remove() second argument is not optional
Bram Moolenaar <Bram@vim.org>
parents: 15928
diff changeset
211 call assert_equal(props, prop_list(lnum, {'bufnr': bufnr}))
176872829dc2 patch 8.1.1035: prop_remove() second argument is not optional
Bram Moolenaar <Bram@vim.org>
parents: 15928
diff changeset
212 endfor
15138
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
213
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
214 " remove by type
16060
176872829dc2 patch 8.1.1035: prop_remove() second argument is not optional
Bram Moolenaar <Bram@vim.org>
parents: 15928
diff changeset
215 let before_props = deepcopy(props)
15138
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
216 unlet props[0]
16060
176872829dc2 patch 8.1.1035: prop_remove() second argument is not optional
Bram Moolenaar <Bram@vim.org>
parents: 15928
diff changeset
217
176872829dc2 patch 8.1.1035: prop_remove() second argument is not optional
Bram Moolenaar <Bram@vim.org>
parents: 15928
diff changeset
218 call prop_remove({'type': 'one', 'bufnr': bufnr}, 1)
15138
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
219 call assert_equal(props, prop_list(1, {'bufnr': bufnr}))
16060
176872829dc2 patch 8.1.1035: prop_remove() second argument is not optional
Bram Moolenaar <Bram@vim.org>
parents: 15928
diff changeset
220 call assert_equal(before_props, prop_list(2, {'bufnr': bufnr}))
176872829dc2 patch 8.1.1035: prop_remove() second argument is not optional
Bram Moolenaar <Bram@vim.org>
parents: 15928
diff changeset
221 call assert_equal(before_props, prop_list(3, {'bufnr': bufnr}))
176872829dc2 patch 8.1.1035: prop_remove() second argument is not optional
Bram Moolenaar <Bram@vim.org>
parents: 15928
diff changeset
222 call assert_equal(before_props, prop_list(4, {'bufnr': bufnr}))
176872829dc2 patch 8.1.1035: prop_remove() second argument is not optional
Bram Moolenaar <Bram@vim.org>
parents: 15928
diff changeset
223
176872829dc2 patch 8.1.1035: prop_remove() second argument is not optional
Bram Moolenaar <Bram@vim.org>
parents: 15928
diff changeset
224 call prop_remove({'type': 'one', 'bufnr': bufnr}, 3, 4)
176872829dc2 patch 8.1.1035: prop_remove() second argument is not optional
Bram Moolenaar <Bram@vim.org>
parents: 15928
diff changeset
225 call assert_equal(props, prop_list(1, {'bufnr': bufnr}))
176872829dc2 patch 8.1.1035: prop_remove() second argument is not optional
Bram Moolenaar <Bram@vim.org>
parents: 15928
diff changeset
226 call assert_equal(before_props, prop_list(2, {'bufnr': bufnr}))
176872829dc2 patch 8.1.1035: prop_remove() second argument is not optional
Bram Moolenaar <Bram@vim.org>
parents: 15928
diff changeset
227 call assert_equal(props, prop_list(3, {'bufnr': bufnr}))
176872829dc2 patch 8.1.1035: prop_remove() second argument is not optional
Bram Moolenaar <Bram@vim.org>
parents: 15928
diff changeset
228 call assert_equal(props, prop_list(4, {'bufnr': bufnr}))
176872829dc2 patch 8.1.1035: prop_remove() second argument is not optional
Bram Moolenaar <Bram@vim.org>
parents: 15928
diff changeset
229
176872829dc2 patch 8.1.1035: prop_remove() second argument is not optional
Bram Moolenaar <Bram@vim.org>
parents: 15928
diff changeset
230 call prop_remove({'type': 'one', 'bufnr': bufnr})
176872829dc2 patch 8.1.1035: prop_remove() second argument is not optional
Bram Moolenaar <Bram@vim.org>
parents: 15928
diff changeset
231 for lnum in range(1, 4)
176872829dc2 patch 8.1.1035: prop_remove() second argument is not optional
Bram Moolenaar <Bram@vim.org>
parents: 15928
diff changeset
232 call assert_equal(props, prop_list(lnum, {'bufnr': bufnr}))
176872829dc2 patch 8.1.1035: prop_remove() second argument is not optional
Bram Moolenaar <Bram@vim.org>
parents: 15928
diff changeset
233 endfor
15138
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
234
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
235 call DeletePropTypes()
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
236 wincmd w
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
237 bwipe!
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
238 endfunc
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
239
15347
f6b522596993 patch 8.1.0681: text properties as not adjusted for deleted text
Bram Moolenaar <Bram@vim.org>
parents: 15341
diff changeset
240 func Test_prop_backspace()
f6b522596993 patch 8.1.0681: text properties as not adjusted for deleted text
Bram Moolenaar <Bram@vim.org>
parents: 15341
diff changeset
241 new
f6b522596993 patch 8.1.0681: text properties as not adjusted for deleted text
Bram Moolenaar <Bram@vim.org>
parents: 15341
diff changeset
242 set bs=2
15349
6abee072b93c patch 8.1.0682: text properties not adjusted when backspacing replaced text
Bram Moolenaar <Bram@vim.org>
parents: 15347
diff changeset
243 let expected = SetupOneLine() " 'xonex xtwoxx'
15347
f6b522596993 patch 8.1.0681: text properties as not adjusted for deleted text
Bram Moolenaar <Bram@vim.org>
parents: 15341
diff changeset
244
f6b522596993 patch 8.1.0681: text properties as not adjusted for deleted text
Bram Moolenaar <Bram@vim.org>
parents: 15341
diff changeset
245 exe "normal 0li\<BS>\<Esc>fxli\<BS>\<Esc>"
f6b522596993 patch 8.1.0681: text properties as not adjusted for deleted text
Bram Moolenaar <Bram@vim.org>
parents: 15341
diff changeset
246 call assert_equal('one xtwoxx', getline(1))
f6b522596993 patch 8.1.0681: text properties as not adjusted for deleted text
Bram Moolenaar <Bram@vim.org>
parents: 15341
diff changeset
247 let expected[0].col = 1
f6b522596993 patch 8.1.0681: text properties as not adjusted for deleted text
Bram Moolenaar <Bram@vim.org>
parents: 15341
diff changeset
248 let expected[1].col = 6
f6b522596993 patch 8.1.0681: text properties as not adjusted for deleted text
Bram Moolenaar <Bram@vim.org>
parents: 15341
diff changeset
249 call assert_equal(expected, prop_list(1))
f6b522596993 patch 8.1.0681: text properties as not adjusted for deleted text
Bram Moolenaar <Bram@vim.org>
parents: 15341
diff changeset
250
f6b522596993 patch 8.1.0681: text properties as not adjusted for deleted text
Bram Moolenaar <Bram@vim.org>
parents: 15341
diff changeset
251 call DeletePropTypes()
f6b522596993 patch 8.1.0681: text properties as not adjusted for deleted text
Bram Moolenaar <Bram@vim.org>
parents: 15341
diff changeset
252 bwipe!
f6b522596993 patch 8.1.0681: text properties as not adjusted for deleted text
Bram Moolenaar <Bram@vim.org>
parents: 15341
diff changeset
253 set bs&
f6b522596993 patch 8.1.0681: text properties as not adjusted for deleted text
Bram Moolenaar <Bram@vim.org>
parents: 15341
diff changeset
254 endfunc
15138
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
255
15349
6abee072b93c patch 8.1.0682: text properties not adjusted when backspacing replaced text
Bram Moolenaar <Bram@vim.org>
parents: 15347
diff changeset
256 func Test_prop_replace()
6abee072b93c patch 8.1.0682: text properties not adjusted when backspacing replaced text
Bram Moolenaar <Bram@vim.org>
parents: 15347
diff changeset
257 new
6abee072b93c patch 8.1.0682: text properties not adjusted when backspacing replaced text
Bram Moolenaar <Bram@vim.org>
parents: 15347
diff changeset
258 set bs=2
6abee072b93c patch 8.1.0682: text properties not adjusted when backspacing replaced text
Bram Moolenaar <Bram@vim.org>
parents: 15347
diff changeset
259 let expected = SetupOneLine() " 'xonex xtwoxx'
6abee072b93c patch 8.1.0682: text properties not adjusted when backspacing replaced text
Bram Moolenaar <Bram@vim.org>
parents: 15347
diff changeset
260
6abee072b93c patch 8.1.0682: text properties not adjusted when backspacing replaced text
Bram Moolenaar <Bram@vim.org>
parents: 15347
diff changeset
261 exe "normal 0Ryyy\<Esc>"
6abee072b93c patch 8.1.0682: text properties not adjusted when backspacing replaced text
Bram Moolenaar <Bram@vim.org>
parents: 15347
diff changeset
262 call assert_equal('yyyex xtwoxx', getline(1))
6abee072b93c patch 8.1.0682: text properties not adjusted when backspacing replaced text
Bram Moolenaar <Bram@vim.org>
parents: 15347
diff changeset
263 call assert_equal(expected, prop_list(1))
6abee072b93c patch 8.1.0682: text properties not adjusted when backspacing replaced text
Bram Moolenaar <Bram@vim.org>
parents: 15347
diff changeset
264
6abee072b93c patch 8.1.0682: text properties not adjusted when backspacing replaced text
Bram Moolenaar <Bram@vim.org>
parents: 15347
diff changeset
265 exe "normal ftRyy\<BS>"
6abee072b93c patch 8.1.0682: text properties not adjusted when backspacing replaced text
Bram Moolenaar <Bram@vim.org>
parents: 15347
diff changeset
266 call assert_equal('yyyex xywoxx', getline(1))
6abee072b93c patch 8.1.0682: text properties not adjusted when backspacing replaced text
Bram Moolenaar <Bram@vim.org>
parents: 15347
diff changeset
267 call assert_equal(expected, prop_list(1))
6abee072b93c patch 8.1.0682: text properties not adjusted when backspacing replaced text
Bram Moolenaar <Bram@vim.org>
parents: 15347
diff changeset
268
6abee072b93c patch 8.1.0682: text properties not adjusted when backspacing replaced text
Bram Moolenaar <Bram@vim.org>
parents: 15347
diff changeset
269 exe "normal 0fwRyy\<BS>"
6abee072b93c patch 8.1.0682: text properties not adjusted when backspacing replaced text
Bram Moolenaar <Bram@vim.org>
parents: 15347
diff changeset
270 call assert_equal('yyyex xyyoxx', getline(1))
6abee072b93c patch 8.1.0682: text properties not adjusted when backspacing replaced text
Bram Moolenaar <Bram@vim.org>
parents: 15347
diff changeset
271 call assert_equal(expected, prop_list(1))
6abee072b93c patch 8.1.0682: text properties not adjusted when backspacing replaced text
Bram Moolenaar <Bram@vim.org>
parents: 15347
diff changeset
272
6abee072b93c patch 8.1.0682: text properties not adjusted when backspacing replaced text
Bram Moolenaar <Bram@vim.org>
parents: 15347
diff changeset
273 exe "normal 0foRyy\<BS>\<BS>"
6abee072b93c patch 8.1.0682: text properties not adjusted when backspacing replaced text
Bram Moolenaar <Bram@vim.org>
parents: 15347
diff changeset
274 call assert_equal('yyyex xyyoxx', getline(1))
6abee072b93c patch 8.1.0682: text properties not adjusted when backspacing replaced text
Bram Moolenaar <Bram@vim.org>
parents: 15347
diff changeset
275 call assert_equal(expected, prop_list(1))
6abee072b93c patch 8.1.0682: text properties not adjusted when backspacing replaced text
Bram Moolenaar <Bram@vim.org>
parents: 15347
diff changeset
276
6abee072b93c patch 8.1.0682: text properties not adjusted when backspacing replaced text
Bram Moolenaar <Bram@vim.org>
parents: 15347
diff changeset
277 call DeletePropTypes()
6abee072b93c patch 8.1.0682: text properties not adjusted when backspacing replaced text
Bram Moolenaar <Bram@vim.org>
parents: 15347
diff changeset
278 bwipe!
6abee072b93c patch 8.1.0682: text properties not adjusted when backspacing replaced text
Bram Moolenaar <Bram@vim.org>
parents: 15347
diff changeset
279 set bs&
6abee072b93c patch 8.1.0682: text properties not adjusted when backspacing replaced text
Bram Moolenaar <Bram@vim.org>
parents: 15347
diff changeset
280 endfunc
6abee072b93c patch 8.1.0682: text properties not adjusted when backspacing replaced text
Bram Moolenaar <Bram@vim.org>
parents: 15347
diff changeset
281
16662
1fc9cd08cf3c patch 8.1.1333: text properties don't always move after changes
Bram Moolenaar <Bram@vim.org>
parents: 16545
diff changeset
282 func Test_prop_open_line()
1fc9cd08cf3c patch 8.1.1333: text properties don't always move after changes
Bram Moolenaar <Bram@vim.org>
parents: 16545
diff changeset
283 new
1fc9cd08cf3c patch 8.1.1333: text properties don't always move after changes
Bram Moolenaar <Bram@vim.org>
parents: 16545
diff changeset
284
1fc9cd08cf3c patch 8.1.1333: text properties don't always move after changes
Bram Moolenaar <Bram@vim.org>
parents: 16545
diff changeset
285 " open new line, props stay in top line
1fc9cd08cf3c patch 8.1.1333: text properties don't always move after changes
Bram Moolenaar <Bram@vim.org>
parents: 16545
diff changeset
286 let expected = SetupOneLine() " 'xonex xtwoxx'
1fc9cd08cf3c patch 8.1.1333: text properties don't always move after changes
Bram Moolenaar <Bram@vim.org>
parents: 16545
diff changeset
287 exe "normal o\<Esc>"
1fc9cd08cf3c patch 8.1.1333: text properties don't always move after changes
Bram Moolenaar <Bram@vim.org>
parents: 16545
diff changeset
288 call assert_equal('xonex xtwoxx', getline(1))
1fc9cd08cf3c patch 8.1.1333: text properties don't always move after changes
Bram Moolenaar <Bram@vim.org>
parents: 16545
diff changeset
289 call assert_equal('', getline(2))
1fc9cd08cf3c patch 8.1.1333: text properties don't always move after changes
Bram Moolenaar <Bram@vim.org>
parents: 16545
diff changeset
290 call assert_equal(expected, prop_list(1))
1fc9cd08cf3c patch 8.1.1333: text properties don't always move after changes
Bram Moolenaar <Bram@vim.org>
parents: 16545
diff changeset
291 call DeletePropTypes()
1fc9cd08cf3c patch 8.1.1333: text properties don't always move after changes
Bram Moolenaar <Bram@vim.org>
parents: 16545
diff changeset
292
1fc9cd08cf3c patch 8.1.1333: text properties don't always move after changes
Bram Moolenaar <Bram@vim.org>
parents: 16545
diff changeset
293 " move all props to next line
1fc9cd08cf3c patch 8.1.1333: text properties don't always move after changes
Bram Moolenaar <Bram@vim.org>
parents: 16545
diff changeset
294 let expected = SetupOneLine() " 'xonex xtwoxx'
1fc9cd08cf3c patch 8.1.1333: text properties don't always move after changes
Bram Moolenaar <Bram@vim.org>
parents: 16545
diff changeset
295 exe "normal 0i\<CR>\<Esc>"
1fc9cd08cf3c patch 8.1.1333: text properties don't always move after changes
Bram Moolenaar <Bram@vim.org>
parents: 16545
diff changeset
296 call assert_equal('', getline(1))
1fc9cd08cf3c patch 8.1.1333: text properties don't always move after changes
Bram Moolenaar <Bram@vim.org>
parents: 16545
diff changeset
297 call assert_equal('xonex xtwoxx', getline(2))
1fc9cd08cf3c patch 8.1.1333: text properties don't always move after changes
Bram Moolenaar <Bram@vim.org>
parents: 16545
diff changeset
298 call assert_equal(expected, prop_list(2))
1fc9cd08cf3c patch 8.1.1333: text properties don't always move after changes
Bram Moolenaar <Bram@vim.org>
parents: 16545
diff changeset
299 call DeletePropTypes()
1fc9cd08cf3c patch 8.1.1333: text properties don't always move after changes
Bram Moolenaar <Bram@vim.org>
parents: 16545
diff changeset
300
1fc9cd08cf3c patch 8.1.1333: text properties don't always move after changes
Bram Moolenaar <Bram@vim.org>
parents: 16545
diff changeset
301 " split just before prop, move all props to next line
1fc9cd08cf3c patch 8.1.1333: text properties don't always move after changes
Bram Moolenaar <Bram@vim.org>
parents: 16545
diff changeset
302 let expected = SetupOneLine() " 'xonex xtwoxx'
1fc9cd08cf3c patch 8.1.1333: text properties don't always move after changes
Bram Moolenaar <Bram@vim.org>
parents: 16545
diff changeset
303 exe "normal 0li\<CR>\<Esc>"
1fc9cd08cf3c patch 8.1.1333: text properties don't always move after changes
Bram Moolenaar <Bram@vim.org>
parents: 16545
diff changeset
304 call assert_equal('x', getline(1))
1fc9cd08cf3c patch 8.1.1333: text properties don't always move after changes
Bram Moolenaar <Bram@vim.org>
parents: 16545
diff changeset
305 call assert_equal('onex xtwoxx', getline(2))
1fc9cd08cf3c patch 8.1.1333: text properties don't always move after changes
Bram Moolenaar <Bram@vim.org>
parents: 16545
diff changeset
306 let expected[0].col -= 1
1fc9cd08cf3c patch 8.1.1333: text properties don't always move after changes
Bram Moolenaar <Bram@vim.org>
parents: 16545
diff changeset
307 let expected[1].col -= 1
1fc9cd08cf3c patch 8.1.1333: text properties don't always move after changes
Bram Moolenaar <Bram@vim.org>
parents: 16545
diff changeset
308 call assert_equal(expected, prop_list(2))
1fc9cd08cf3c patch 8.1.1333: text properties don't always move after changes
Bram Moolenaar <Bram@vim.org>
parents: 16545
diff changeset
309 call DeletePropTypes()
1fc9cd08cf3c patch 8.1.1333: text properties don't always move after changes
Bram Moolenaar <Bram@vim.org>
parents: 16545
diff changeset
310
1fc9cd08cf3c patch 8.1.1333: text properties don't always move after changes
Bram Moolenaar <Bram@vim.org>
parents: 16545
diff changeset
311 " split inside prop, split first prop
1fc9cd08cf3c patch 8.1.1333: text properties don't always move after changes
Bram Moolenaar <Bram@vim.org>
parents: 16545
diff changeset
312 let expected = SetupOneLine() " 'xonex xtwoxx'
1fc9cd08cf3c patch 8.1.1333: text properties don't always move after changes
Bram Moolenaar <Bram@vim.org>
parents: 16545
diff changeset
313 exe "normal 0lli\<CR>\<Esc>"
1fc9cd08cf3c patch 8.1.1333: text properties don't always move after changes
Bram Moolenaar <Bram@vim.org>
parents: 16545
diff changeset
314 call assert_equal('xo', getline(1))
1fc9cd08cf3c patch 8.1.1333: text properties don't always move after changes
Bram Moolenaar <Bram@vim.org>
parents: 16545
diff changeset
315 call assert_equal('nex xtwoxx', getline(2))
1fc9cd08cf3c patch 8.1.1333: text properties don't always move after changes
Bram Moolenaar <Bram@vim.org>
parents: 16545
diff changeset
316 let exp_first = [deepcopy(expected[0])]
1fc9cd08cf3c patch 8.1.1333: text properties don't always move after changes
Bram Moolenaar <Bram@vim.org>
parents: 16545
diff changeset
317 let exp_first[0].length = 1
1fc9cd08cf3c patch 8.1.1333: text properties don't always move after changes
Bram Moolenaar <Bram@vim.org>
parents: 16545
diff changeset
318 call assert_equal(exp_first, prop_list(1))
1fc9cd08cf3c patch 8.1.1333: text properties don't always move after changes
Bram Moolenaar <Bram@vim.org>
parents: 16545
diff changeset
319 let expected[0].col = 1
1fc9cd08cf3c patch 8.1.1333: text properties don't always move after changes
Bram Moolenaar <Bram@vim.org>
parents: 16545
diff changeset
320 let expected[0].length = 2
1fc9cd08cf3c patch 8.1.1333: text properties don't always move after changes
Bram Moolenaar <Bram@vim.org>
parents: 16545
diff changeset
321 let expected[1].col -= 2
1fc9cd08cf3c patch 8.1.1333: text properties don't always move after changes
Bram Moolenaar <Bram@vim.org>
parents: 16545
diff changeset
322 call assert_equal(expected, prop_list(2))
1fc9cd08cf3c patch 8.1.1333: text properties don't always move after changes
Bram Moolenaar <Bram@vim.org>
parents: 16545
diff changeset
323 call DeletePropTypes()
1fc9cd08cf3c patch 8.1.1333: text properties don't always move after changes
Bram Moolenaar <Bram@vim.org>
parents: 16545
diff changeset
324
16670
5733d8e33bce patch 8.1.1337: get empty text prop when splitting line just after text prop
Bram Moolenaar <Bram@vim.org>
parents: 16662
diff changeset
325 " split just after first prop, second prop move to next line
16662
1fc9cd08cf3c patch 8.1.1333: text properties don't always move after changes
Bram Moolenaar <Bram@vim.org>
parents: 16545
diff changeset
326 let expected = SetupOneLine() " 'xonex xtwoxx'
1fc9cd08cf3c patch 8.1.1333: text properties don't always move after changes
Bram Moolenaar <Bram@vim.org>
parents: 16545
diff changeset
327 exe "normal 0fea\<CR>\<Esc>"
1fc9cd08cf3c patch 8.1.1333: text properties don't always move after changes
Bram Moolenaar <Bram@vim.org>
parents: 16545
diff changeset
328 call assert_equal('xone', getline(1))
1fc9cd08cf3c patch 8.1.1333: text properties don't always move after changes
Bram Moolenaar <Bram@vim.org>
parents: 16545
diff changeset
329 call assert_equal('x xtwoxx', getline(2))
1fc9cd08cf3c patch 8.1.1333: text properties don't always move after changes
Bram Moolenaar <Bram@vim.org>
parents: 16545
diff changeset
330 let exp_first = expected[0:0]
1fc9cd08cf3c patch 8.1.1333: text properties don't always move after changes
Bram Moolenaar <Bram@vim.org>
parents: 16545
diff changeset
331 call assert_equal(exp_first, prop_list(1))
16670
5733d8e33bce patch 8.1.1337: get empty text prop when splitting line just after text prop
Bram Moolenaar <Bram@vim.org>
parents: 16662
diff changeset
332 let expected = expected[1:1]
5733d8e33bce patch 8.1.1337: get empty text prop when splitting line just after text prop
Bram Moolenaar <Bram@vim.org>
parents: 16662
diff changeset
333 let expected[0].col -= 4
16662
1fc9cd08cf3c patch 8.1.1333: text properties don't always move after changes
Bram Moolenaar <Bram@vim.org>
parents: 16545
diff changeset
334 call assert_equal(expected, prop_list(2))
1fc9cd08cf3c patch 8.1.1333: text properties don't always move after changes
Bram Moolenaar <Bram@vim.org>
parents: 16545
diff changeset
335 call DeletePropTypes()
1fc9cd08cf3c patch 8.1.1333: text properties don't always move after changes
Bram Moolenaar <Bram@vim.org>
parents: 16545
diff changeset
336
1fc9cd08cf3c patch 8.1.1333: text properties don't always move after changes
Bram Moolenaar <Bram@vim.org>
parents: 16545
diff changeset
337 bwipe!
1fc9cd08cf3c patch 8.1.1333: text properties don't always move after changes
Bram Moolenaar <Bram@vim.org>
parents: 16545
diff changeset
338 set bs&
1fc9cd08cf3c patch 8.1.1333: text properties don't always move after changes
Bram Moolenaar <Bram@vim.org>
parents: 16545
diff changeset
339 endfunc
1fc9cd08cf3c patch 8.1.1333: text properties don't always move after changes
Bram Moolenaar <Bram@vim.org>
parents: 16545
diff changeset
340
15138
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
341 func Test_prop_clear()
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
342 new
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
343 call AddPropTypes()
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
344 call SetupPropsInFirstLine()
15367
273649cad196 patch 8.1.0691: text properties are not adjusted for :substitute
Bram Moolenaar <Bram@vim.org>
parents: 15365
diff changeset
345 call assert_equal(Get_expected_props(), prop_list(1))
15138
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
346
17980
52f23198af7f patch 8.1.1986: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17694
diff changeset
347 eval 1->prop_clear()
52f23198af7f patch 8.1.1986: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17694
diff changeset
348 call assert_equal([], 1->prop_list())
15138
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
349
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
350 call DeletePropTypes()
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
351 bwipe!
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
352 endfunc
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
353
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
354 func Test_prop_clear_buf()
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
355 new
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
356 call AddPropTypes()
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
357 call SetupPropsInFirstLine()
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
358 let bufnr = bufnr('')
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
359 wincmd w
15367
273649cad196 patch 8.1.0691: text properties are not adjusted for :substitute
Bram Moolenaar <Bram@vim.org>
parents: 15365
diff changeset
360 call assert_equal(Get_expected_props(), prop_list(1, {'bufnr': bufnr}))
15138
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
361
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
362 call prop_clear(1, 1, {'bufnr': bufnr})
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
363 call assert_equal([], prop_list(1, {'bufnr': bufnr}))
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
364
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
365 wincmd w
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
366 call DeletePropTypes()
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
367 bwipe!
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
368 endfunc
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
369
15365
01ee8dc12313 patch 8.1.0690: setline() and setbufline() do not clear text properties
Bram Moolenaar <Bram@vim.org>
parents: 15363
diff changeset
370 func Test_prop_setline()
01ee8dc12313 patch 8.1.0690: setline() and setbufline() do not clear text properties
Bram Moolenaar <Bram@vim.org>
parents: 15363
diff changeset
371 new
01ee8dc12313 patch 8.1.0690: setline() and setbufline() do not clear text properties
Bram Moolenaar <Bram@vim.org>
parents: 15363
diff changeset
372 call AddPropTypes()
01ee8dc12313 patch 8.1.0690: setline() and setbufline() do not clear text properties
Bram Moolenaar <Bram@vim.org>
parents: 15363
diff changeset
373 call SetupPropsInFirstLine()
15367
273649cad196 patch 8.1.0691: text properties are not adjusted for :substitute
Bram Moolenaar <Bram@vim.org>
parents: 15365
diff changeset
374 call assert_equal(Get_expected_props(), prop_list(1))
15365
01ee8dc12313 patch 8.1.0690: setline() and setbufline() do not clear text properties
Bram Moolenaar <Bram@vim.org>
parents: 15363
diff changeset
375
01ee8dc12313 patch 8.1.0690: setline() and setbufline() do not clear text properties
Bram Moolenaar <Bram@vim.org>
parents: 15363
diff changeset
376 call setline(1, 'foobar')
01ee8dc12313 patch 8.1.0690: setline() and setbufline() do not clear text properties
Bram Moolenaar <Bram@vim.org>
parents: 15363
diff changeset
377 call assert_equal([], prop_list(1))
01ee8dc12313 patch 8.1.0690: setline() and setbufline() do not clear text properties
Bram Moolenaar <Bram@vim.org>
parents: 15363
diff changeset
378
01ee8dc12313 patch 8.1.0690: setline() and setbufline() do not clear text properties
Bram Moolenaar <Bram@vim.org>
parents: 15363
diff changeset
379 call DeletePropTypes()
01ee8dc12313 patch 8.1.0690: setline() and setbufline() do not clear text properties
Bram Moolenaar <Bram@vim.org>
parents: 15363
diff changeset
380 bwipe!
01ee8dc12313 patch 8.1.0690: setline() and setbufline() do not clear text properties
Bram Moolenaar <Bram@vim.org>
parents: 15363
diff changeset
381 endfunc
01ee8dc12313 patch 8.1.0690: setline() and setbufline() do not clear text properties
Bram Moolenaar <Bram@vim.org>
parents: 15363
diff changeset
382
01ee8dc12313 patch 8.1.0690: setline() and setbufline() do not clear text properties
Bram Moolenaar <Bram@vim.org>
parents: 15363
diff changeset
383 func Test_prop_setbufline()
01ee8dc12313 patch 8.1.0690: setline() and setbufline() do not clear text properties
Bram Moolenaar <Bram@vim.org>
parents: 15363
diff changeset
384 new
01ee8dc12313 patch 8.1.0690: setline() and setbufline() do not clear text properties
Bram Moolenaar <Bram@vim.org>
parents: 15363
diff changeset
385 call AddPropTypes()
01ee8dc12313 patch 8.1.0690: setline() and setbufline() do not clear text properties
Bram Moolenaar <Bram@vim.org>
parents: 15363
diff changeset
386 call SetupPropsInFirstLine()
01ee8dc12313 patch 8.1.0690: setline() and setbufline() do not clear text properties
Bram Moolenaar <Bram@vim.org>
parents: 15363
diff changeset
387 let bufnr = bufnr('')
01ee8dc12313 patch 8.1.0690: setline() and setbufline() do not clear text properties
Bram Moolenaar <Bram@vim.org>
parents: 15363
diff changeset
388 wincmd w
15367
273649cad196 patch 8.1.0691: text properties are not adjusted for :substitute
Bram Moolenaar <Bram@vim.org>
parents: 15365
diff changeset
389 call assert_equal(Get_expected_props(), prop_list(1, {'bufnr': bufnr}))
15365
01ee8dc12313 patch 8.1.0690: setline() and setbufline() do not clear text properties
Bram Moolenaar <Bram@vim.org>
parents: 15363
diff changeset
390
01ee8dc12313 patch 8.1.0690: setline() and setbufline() do not clear text properties
Bram Moolenaar <Bram@vim.org>
parents: 15363
diff changeset
391 call setbufline(bufnr, 1, 'foobar')
01ee8dc12313 patch 8.1.0690: setline() and setbufline() do not clear text properties
Bram Moolenaar <Bram@vim.org>
parents: 15363
diff changeset
392 call assert_equal([], prop_list(1, {'bufnr': bufnr}))
01ee8dc12313 patch 8.1.0690: setline() and setbufline() do not clear text properties
Bram Moolenaar <Bram@vim.org>
parents: 15363
diff changeset
393
01ee8dc12313 patch 8.1.0690: setline() and setbufline() do not clear text properties
Bram Moolenaar <Bram@vim.org>
parents: 15363
diff changeset
394 wincmd w
01ee8dc12313 patch 8.1.0690: setline() and setbufline() do not clear text properties
Bram Moolenaar <Bram@vim.org>
parents: 15363
diff changeset
395 call DeletePropTypes()
01ee8dc12313 patch 8.1.0690: setline() and setbufline() do not clear text properties
Bram Moolenaar <Bram@vim.org>
parents: 15363
diff changeset
396 bwipe!
01ee8dc12313 patch 8.1.0690: setline() and setbufline() do not clear text properties
Bram Moolenaar <Bram@vim.org>
parents: 15363
diff changeset
397 endfunc
01ee8dc12313 patch 8.1.0690: setline() and setbufline() do not clear text properties
Bram Moolenaar <Bram@vim.org>
parents: 15363
diff changeset
398
15367
273649cad196 patch 8.1.0691: text properties are not adjusted for :substitute
Bram Moolenaar <Bram@vim.org>
parents: 15365
diff changeset
399 func Test_prop_substitute()
273649cad196 patch 8.1.0691: text properties are not adjusted for :substitute
Bram Moolenaar <Bram@vim.org>
parents: 15365
diff changeset
400 new
273649cad196 patch 8.1.0691: text properties are not adjusted for :substitute
Bram Moolenaar <Bram@vim.org>
parents: 15365
diff changeset
401 " Set first line to 'one two three'
273649cad196 patch 8.1.0691: text properties are not adjusted for :substitute
Bram Moolenaar <Bram@vim.org>
parents: 15365
diff changeset
402 call AddPropTypes()
273649cad196 patch 8.1.0691: text properties are not adjusted for :substitute
Bram Moolenaar <Bram@vim.org>
parents: 15365
diff changeset
403 call SetupPropsInFirstLine()
273649cad196 patch 8.1.0691: text properties are not adjusted for :substitute
Bram Moolenaar <Bram@vim.org>
parents: 15365
diff changeset
404 let expected_props = Get_expected_props()
273649cad196 patch 8.1.0691: text properties are not adjusted for :substitute
Bram Moolenaar <Bram@vim.org>
parents: 15365
diff changeset
405 call assert_equal(expected_props, prop_list(1))
273649cad196 patch 8.1.0691: text properties are not adjusted for :substitute
Bram Moolenaar <Bram@vim.org>
parents: 15365
diff changeset
406
273649cad196 patch 8.1.0691: text properties are not adjusted for :substitute
Bram Moolenaar <Bram@vim.org>
parents: 15365
diff changeset
407 " Change "n" in "one" to XX: 'oXXe two three'
273649cad196 patch 8.1.0691: text properties are not adjusted for :substitute
Bram Moolenaar <Bram@vim.org>
parents: 15365
diff changeset
408 s/n/XX/
273649cad196 patch 8.1.0691: text properties are not adjusted for :substitute
Bram Moolenaar <Bram@vim.org>
parents: 15365
diff changeset
409 let expected_props[0].length += 1
273649cad196 patch 8.1.0691: text properties are not adjusted for :substitute
Bram Moolenaar <Bram@vim.org>
parents: 15365
diff changeset
410 let expected_props[1].length += 1
273649cad196 patch 8.1.0691: text properties are not adjusted for :substitute
Bram Moolenaar <Bram@vim.org>
parents: 15365
diff changeset
411 let expected_props[2].col += 1
273649cad196 patch 8.1.0691: text properties are not adjusted for :substitute
Bram Moolenaar <Bram@vim.org>
parents: 15365
diff changeset
412 let expected_props[3].col += 1
273649cad196 patch 8.1.0691: text properties are not adjusted for :substitute
Bram Moolenaar <Bram@vim.org>
parents: 15365
diff changeset
413 call assert_equal(expected_props, prop_list(1))
273649cad196 patch 8.1.0691: text properties are not adjusted for :substitute
Bram Moolenaar <Bram@vim.org>
parents: 15365
diff changeset
414
273649cad196 patch 8.1.0691: text properties are not adjusted for :substitute
Bram Moolenaar <Bram@vim.org>
parents: 15365
diff changeset
415 " Delete "t" in "two" and "three" to XX: 'oXXe wo hree'
273649cad196 patch 8.1.0691: text properties are not adjusted for :substitute
Bram Moolenaar <Bram@vim.org>
parents: 15365
diff changeset
416 s/t//g
273649cad196 patch 8.1.0691: text properties are not adjusted for :substitute
Bram Moolenaar <Bram@vim.org>
parents: 15365
diff changeset
417 let expected_props[0].length -= 2
273649cad196 patch 8.1.0691: text properties are not adjusted for :substitute
Bram Moolenaar <Bram@vim.org>
parents: 15365
diff changeset
418 let expected_props[2].length -= 1
273649cad196 patch 8.1.0691: text properties are not adjusted for :substitute
Bram Moolenaar <Bram@vim.org>
parents: 15365
diff changeset
419 let expected_props[3].length -= 1
273649cad196 patch 8.1.0691: text properties are not adjusted for :substitute
Bram Moolenaar <Bram@vim.org>
parents: 15365
diff changeset
420 let expected_props[3].col -= 1
273649cad196 patch 8.1.0691: text properties are not adjusted for :substitute
Bram Moolenaar <Bram@vim.org>
parents: 15365
diff changeset
421 call assert_equal(expected_props, prop_list(1))
273649cad196 patch 8.1.0691: text properties are not adjusted for :substitute
Bram Moolenaar <Bram@vim.org>
parents: 15365
diff changeset
422
273649cad196 patch 8.1.0691: text properties are not adjusted for :substitute
Bram Moolenaar <Bram@vim.org>
parents: 15365
diff changeset
423 " Split the line by changing w to line break: 'oXXe ', 'o hree'
273649cad196 patch 8.1.0691: text properties are not adjusted for :substitute
Bram Moolenaar <Bram@vim.org>
parents: 15365
diff changeset
424 " The long prop is split and spans both lines.
273649cad196 patch 8.1.0691: text properties are not adjusted for :substitute
Bram Moolenaar <Bram@vim.org>
parents: 15365
diff changeset
425 " The props on "two" and "three" move to the next line.
273649cad196 patch 8.1.0691: text properties are not adjusted for :substitute
Bram Moolenaar <Bram@vim.org>
parents: 15365
diff changeset
426 s/w/\r/
273649cad196 patch 8.1.0691: text properties are not adjusted for :substitute
Bram Moolenaar <Bram@vim.org>
parents: 15365
diff changeset
427 let new_props = [
273649cad196 patch 8.1.0691: text properties are not adjusted for :substitute
Bram Moolenaar <Bram@vim.org>
parents: 15365
diff changeset
428 \ copy(expected_props[0]),
273649cad196 patch 8.1.0691: text properties are not adjusted for :substitute
Bram Moolenaar <Bram@vim.org>
parents: 15365
diff changeset
429 \ copy(expected_props[2]),
273649cad196 patch 8.1.0691: text properties are not adjusted for :substitute
Bram Moolenaar <Bram@vim.org>
parents: 15365
diff changeset
430 \ copy(expected_props[3]),
273649cad196 patch 8.1.0691: text properties are not adjusted for :substitute
Bram Moolenaar <Bram@vim.org>
parents: 15365
diff changeset
431 \ ]
273649cad196 patch 8.1.0691: text properties are not adjusted for :substitute
Bram Moolenaar <Bram@vim.org>
parents: 15365
diff changeset
432 let expected_props[0].length = 5
273649cad196 patch 8.1.0691: text properties are not adjusted for :substitute
Bram Moolenaar <Bram@vim.org>
parents: 15365
diff changeset
433 unlet expected_props[3]
273649cad196 patch 8.1.0691: text properties are not adjusted for :substitute
Bram Moolenaar <Bram@vim.org>
parents: 15365
diff changeset
434 unlet expected_props[2]
273649cad196 patch 8.1.0691: text properties are not adjusted for :substitute
Bram Moolenaar <Bram@vim.org>
parents: 15365
diff changeset
435 call assert_equal(expected_props, prop_list(1))
273649cad196 patch 8.1.0691: text properties are not adjusted for :substitute
Bram Moolenaar <Bram@vim.org>
parents: 15365
diff changeset
436
273649cad196 patch 8.1.0691: text properties are not adjusted for :substitute
Bram Moolenaar <Bram@vim.org>
parents: 15365
diff changeset
437 let new_props[0].length = 6
273649cad196 patch 8.1.0691: text properties are not adjusted for :substitute
Bram Moolenaar <Bram@vim.org>
parents: 15365
diff changeset
438 let new_props[1].col = 1
273649cad196 patch 8.1.0691: text properties are not adjusted for :substitute
Bram Moolenaar <Bram@vim.org>
parents: 15365
diff changeset
439 let new_props[1].length = 1
273649cad196 patch 8.1.0691: text properties are not adjusted for :substitute
Bram Moolenaar <Bram@vim.org>
parents: 15365
diff changeset
440 let new_props[2].col = 3
273649cad196 patch 8.1.0691: text properties are not adjusted for :substitute
Bram Moolenaar <Bram@vim.org>
parents: 15365
diff changeset
441 call assert_equal(new_props, prop_list(2))
273649cad196 patch 8.1.0691: text properties are not adjusted for :substitute
Bram Moolenaar <Bram@vim.org>
parents: 15365
diff changeset
442
273649cad196 patch 8.1.0691: text properties are not adjusted for :substitute
Bram Moolenaar <Bram@vim.org>
parents: 15365
diff changeset
443 call DeletePropTypes()
273649cad196 patch 8.1.0691: text properties are not adjusted for :substitute
Bram Moolenaar <Bram@vim.org>
parents: 15365
diff changeset
444 bwipe!
273649cad196 patch 8.1.0691: text properties are not adjusted for :substitute
Bram Moolenaar <Bram@vim.org>
parents: 15365
diff changeset
445 endfunc
273649cad196 patch 8.1.0691: text properties are not adjusted for :substitute
Bram Moolenaar <Bram@vim.org>
parents: 15365
diff changeset
446
15398
3e02464faaac patch 8.1.0707: text property columns are not adjusted for changed indent
Bram Moolenaar <Bram@vim.org>
parents: 15367
diff changeset
447 func Test_prop_change_indent()
3e02464faaac patch 8.1.0707: text property columns are not adjusted for changed indent
Bram Moolenaar <Bram@vim.org>
parents: 15367
diff changeset
448 call prop_type_add('comment', {'highlight': 'Directory'})
3e02464faaac patch 8.1.0707: text property columns are not adjusted for changed indent
Bram Moolenaar <Bram@vim.org>
parents: 15367
diff changeset
449 new
3e02464faaac patch 8.1.0707: text property columns are not adjusted for changed indent
Bram Moolenaar <Bram@vim.org>
parents: 15367
diff changeset
450 call setline(1, [' xxx', 'yyyyy'])
3e02464faaac patch 8.1.0707: text property columns are not adjusted for changed indent
Bram Moolenaar <Bram@vim.org>
parents: 15367
diff changeset
451 call prop_add(2, 2, {'length': 2, 'type': 'comment'})
3e02464faaac patch 8.1.0707: text property columns are not adjusted for changed indent
Bram Moolenaar <Bram@vim.org>
parents: 15367
diff changeset
452 let expect = {'col': 2, 'length': 2, 'type': 'comment', 'start': 1, 'end': 1, 'id': 0}
3e02464faaac patch 8.1.0707: text property columns are not adjusted for changed indent
Bram Moolenaar <Bram@vim.org>
parents: 15367
diff changeset
453 call assert_equal([expect], prop_list(2))
3e02464faaac patch 8.1.0707: text property columns are not adjusted for changed indent
Bram Moolenaar <Bram@vim.org>
parents: 15367
diff changeset
454
3e02464faaac patch 8.1.0707: text property columns are not adjusted for changed indent
Bram Moolenaar <Bram@vim.org>
parents: 15367
diff changeset
455 set shiftwidth=3
3e02464faaac patch 8.1.0707: text property columns are not adjusted for changed indent
Bram Moolenaar <Bram@vim.org>
parents: 15367
diff changeset
456 normal 2G>>
3e02464faaac patch 8.1.0707: text property columns are not adjusted for changed indent
Bram Moolenaar <Bram@vim.org>
parents: 15367
diff changeset
457 call assert_equal(' yyyyy', getline(2))
3e02464faaac patch 8.1.0707: text property columns are not adjusted for changed indent
Bram Moolenaar <Bram@vim.org>
parents: 15367
diff changeset
458 let expect.col += 3
3e02464faaac patch 8.1.0707: text property columns are not adjusted for changed indent
Bram Moolenaar <Bram@vim.org>
parents: 15367
diff changeset
459 call assert_equal([expect], prop_list(2))
3e02464faaac patch 8.1.0707: text property columns are not adjusted for changed indent
Bram Moolenaar <Bram@vim.org>
parents: 15367
diff changeset
460
3e02464faaac patch 8.1.0707: text property columns are not adjusted for changed indent
Bram Moolenaar <Bram@vim.org>
parents: 15367
diff changeset
461 normal 2G==
3e02464faaac patch 8.1.0707: text property columns are not adjusted for changed indent
Bram Moolenaar <Bram@vim.org>
parents: 15367
diff changeset
462 call assert_equal(' yyyyy', getline(2))
3e02464faaac patch 8.1.0707: text property columns are not adjusted for changed indent
Bram Moolenaar <Bram@vim.org>
parents: 15367
diff changeset
463 let expect.col = 6
3e02464faaac patch 8.1.0707: text property columns are not adjusted for changed indent
Bram Moolenaar <Bram@vim.org>
parents: 15367
diff changeset
464 call assert_equal([expect], prop_list(2))
3e02464faaac patch 8.1.0707: text property columns are not adjusted for changed indent
Bram Moolenaar <Bram@vim.org>
parents: 15367
diff changeset
465
3e02464faaac patch 8.1.0707: text property columns are not adjusted for changed indent
Bram Moolenaar <Bram@vim.org>
parents: 15367
diff changeset
466 call prop_clear(2)
3e02464faaac patch 8.1.0707: text property columns are not adjusted for changed indent
Bram Moolenaar <Bram@vim.org>
parents: 15367
diff changeset
467 call prop_add(2, 2, {'length': 5, 'type': 'comment'})
3e02464faaac patch 8.1.0707: text property columns are not adjusted for changed indent
Bram Moolenaar <Bram@vim.org>
parents: 15367
diff changeset
468 let expect.col = 2
3e02464faaac patch 8.1.0707: text property columns are not adjusted for changed indent
Bram Moolenaar <Bram@vim.org>
parents: 15367
diff changeset
469 let expect.length = 5
3e02464faaac patch 8.1.0707: text property columns are not adjusted for changed indent
Bram Moolenaar <Bram@vim.org>
parents: 15367
diff changeset
470 call assert_equal([expect], prop_list(2))
3e02464faaac patch 8.1.0707: text property columns are not adjusted for changed indent
Bram Moolenaar <Bram@vim.org>
parents: 15367
diff changeset
471
3e02464faaac patch 8.1.0707: text property columns are not adjusted for changed indent
Bram Moolenaar <Bram@vim.org>
parents: 15367
diff changeset
472 normal 2G<<
3e02464faaac patch 8.1.0707: text property columns are not adjusted for changed indent
Bram Moolenaar <Bram@vim.org>
parents: 15367
diff changeset
473 call assert_equal(' yyyyy', getline(2))
3e02464faaac patch 8.1.0707: text property columns are not adjusted for changed indent
Bram Moolenaar <Bram@vim.org>
parents: 15367
diff changeset
474 let expect.length = 2
3e02464faaac patch 8.1.0707: text property columns are not adjusted for changed indent
Bram Moolenaar <Bram@vim.org>
parents: 15367
diff changeset
475 call assert_equal([expect], prop_list(2))
3e02464faaac patch 8.1.0707: text property columns are not adjusted for changed indent
Bram Moolenaar <Bram@vim.org>
parents: 15367
diff changeset
476
3e02464faaac patch 8.1.0707: text property columns are not adjusted for changed indent
Bram Moolenaar <Bram@vim.org>
parents: 15367
diff changeset
477 set shiftwidth&
3e02464faaac patch 8.1.0707: text property columns are not adjusted for changed indent
Bram Moolenaar <Bram@vim.org>
parents: 15367
diff changeset
478 call prop_type_delete('comment')
3e02464faaac patch 8.1.0707: text property columns are not adjusted for changed indent
Bram Moolenaar <Bram@vim.org>
parents: 15367
diff changeset
479 endfunc
3e02464faaac patch 8.1.0707: text property columns are not adjusted for changed indent
Bram Moolenaar <Bram@vim.org>
parents: 15367
diff changeset
480
15292
ba6f0f1bb9d0 patch 8.1.0654: when deleting a line text property flags are not adjusted
Bram Moolenaar <Bram@vim.org>
parents: 15269
diff changeset
481 " Setup a three line prop in lines 2 - 4.
ba6f0f1bb9d0 patch 8.1.0654: when deleting a line text property flags are not adjusted
Bram Moolenaar <Bram@vim.org>
parents: 15269
diff changeset
482 " Add short props in line 1 and 5.
ba6f0f1bb9d0 patch 8.1.0654: when deleting a line text property flags are not adjusted
Bram Moolenaar <Bram@vim.org>
parents: 15269
diff changeset
483 func Setup_three_line_prop()
ba6f0f1bb9d0 patch 8.1.0654: when deleting a line text property flags are not adjusted
Bram Moolenaar <Bram@vim.org>
parents: 15269
diff changeset
484 new
ba6f0f1bb9d0 patch 8.1.0654: when deleting a line text property flags are not adjusted
Bram Moolenaar <Bram@vim.org>
parents: 15269
diff changeset
485 call setline(1, ['one', 'twotwo', 'three', 'fourfour', 'five'])
ba6f0f1bb9d0 patch 8.1.0654: when deleting a line text property flags are not adjusted
Bram Moolenaar <Bram@vim.org>
parents: 15269
diff changeset
486 call prop_add(1, 2, {'length': 1, 'type': 'comment'})
ba6f0f1bb9d0 patch 8.1.0654: when deleting a line text property flags are not adjusted
Bram Moolenaar <Bram@vim.org>
parents: 15269
diff changeset
487 call prop_add(2, 4, {'end_lnum': 4, 'end_col': 5, 'type': 'comment'})
ba6f0f1bb9d0 patch 8.1.0654: when deleting a line text property flags are not adjusted
Bram Moolenaar <Bram@vim.org>
parents: 15269
diff changeset
488 call prop_add(5, 2, {'length': 1, 'type': 'comment'})
ba6f0f1bb9d0 patch 8.1.0654: when deleting a line text property flags are not adjusted
Bram Moolenaar <Bram@vim.org>
parents: 15269
diff changeset
489 endfunc
ba6f0f1bb9d0 patch 8.1.0654: when deleting a line text property flags are not adjusted
Bram Moolenaar <Bram@vim.org>
parents: 15269
diff changeset
490
15251
17525ca95e1e patch 8.1.0634: text properties cannot cross line boundaries
Bram Moolenaar <Bram@vim.org>
parents: 15138
diff changeset
491 func Test_prop_multiline()
17980
52f23198af7f patch 8.1.1986: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17694
diff changeset
492 eval 'comment'->prop_type_add({'highlight': 'Directory'})
15251
17525ca95e1e patch 8.1.0634: text properties cannot cross line boundaries
Bram Moolenaar <Bram@vim.org>
parents: 15138
diff changeset
493 new
17525ca95e1e patch 8.1.0634: text properties cannot cross line boundaries
Bram Moolenaar <Bram@vim.org>
parents: 15138
diff changeset
494 call setline(1, ['xxxxxxx', 'yyyyyyyyy', 'zzzzzzzz'])
17525ca95e1e patch 8.1.0634: text properties cannot cross line boundaries
Bram Moolenaar <Bram@vim.org>
parents: 15138
diff changeset
495
17525ca95e1e patch 8.1.0634: text properties cannot cross line boundaries
Bram Moolenaar <Bram@vim.org>
parents: 15138
diff changeset
496 " start halfway line 1, end halfway line 3
17525ca95e1e patch 8.1.0634: text properties cannot cross line boundaries
Bram Moolenaar <Bram@vim.org>
parents: 15138
diff changeset
497 call prop_add(1, 3, {'end_lnum': 3, 'end_col': 5, 'type': 'comment'})
17525ca95e1e patch 8.1.0634: text properties cannot cross line boundaries
Bram Moolenaar <Bram@vim.org>
parents: 15138
diff changeset
498 let expect1 = {'col': 3, 'length': 6, 'type': 'comment', 'start': 1, 'end': 0, 'id': 0}
17525ca95e1e patch 8.1.0634: text properties cannot cross line boundaries
Bram Moolenaar <Bram@vim.org>
parents: 15138
diff changeset
499 call assert_equal([expect1], prop_list(1))
17525ca95e1e patch 8.1.0634: text properties cannot cross line boundaries
Bram Moolenaar <Bram@vim.org>
parents: 15138
diff changeset
500 let expect2 = {'col': 1, 'length': 10, 'type': 'comment', 'start': 0, 'end': 0, 'id': 0}
17525ca95e1e patch 8.1.0634: text properties cannot cross line boundaries
Bram Moolenaar <Bram@vim.org>
parents: 15138
diff changeset
501 call assert_equal([expect2], prop_list(2))
15335
18c20ceee4b5 patch 8.1.0675: text property column in screen columns is not practical
Bram Moolenaar <Bram@vim.org>
parents: 15318
diff changeset
502 let expect3 = {'col': 1, 'length': 4, 'type': 'comment', 'start': 0, 'end': 1, 'id': 0}
15251
17525ca95e1e patch 8.1.0634: text properties cannot cross line boundaries
Bram Moolenaar <Bram@vim.org>
parents: 15138
diff changeset
503 call assert_equal([expect3], prop_list(3))
17525ca95e1e patch 8.1.0634: text properties cannot cross line boundaries
Bram Moolenaar <Bram@vim.org>
parents: 15138
diff changeset
504 call prop_clear(1, 3)
17525ca95e1e patch 8.1.0634: text properties cannot cross line boundaries
Bram Moolenaar <Bram@vim.org>
parents: 15138
diff changeset
505
17525ca95e1e patch 8.1.0634: text properties cannot cross line boundaries
Bram Moolenaar <Bram@vim.org>
parents: 15138
diff changeset
506 " include all three lines
17525ca95e1e patch 8.1.0634: text properties cannot cross line boundaries
Bram Moolenaar <Bram@vim.org>
parents: 15138
diff changeset
507 call prop_add(1, 1, {'end_lnum': 3, 'end_col': 999, 'type': 'comment'})
17525ca95e1e patch 8.1.0634: text properties cannot cross line boundaries
Bram Moolenaar <Bram@vim.org>
parents: 15138
diff changeset
508 let expect1.col = 1
17525ca95e1e patch 8.1.0634: text properties cannot cross line boundaries
Bram Moolenaar <Bram@vim.org>
parents: 15138
diff changeset
509 let expect1.length = 8
17525ca95e1e patch 8.1.0634: text properties cannot cross line boundaries
Bram Moolenaar <Bram@vim.org>
parents: 15138
diff changeset
510 call assert_equal([expect1], prop_list(1))
17525ca95e1e patch 8.1.0634: text properties cannot cross line boundaries
Bram Moolenaar <Bram@vim.org>
parents: 15138
diff changeset
511 call assert_equal([expect2], prop_list(2))
17525ca95e1e patch 8.1.0634: text properties cannot cross line boundaries
Bram Moolenaar <Bram@vim.org>
parents: 15138
diff changeset
512 let expect3.length = 9
17525ca95e1e patch 8.1.0634: text properties cannot cross line boundaries
Bram Moolenaar <Bram@vim.org>
parents: 15138
diff changeset
513 call assert_equal([expect3], prop_list(3))
17525ca95e1e patch 8.1.0634: text properties cannot cross line boundaries
Bram Moolenaar <Bram@vim.org>
parents: 15138
diff changeset
514 call prop_clear(1, 3)
17525ca95e1e patch 8.1.0634: text properties cannot cross line boundaries
Bram Moolenaar <Bram@vim.org>
parents: 15138
diff changeset
515
17525ca95e1e patch 8.1.0634: text properties cannot cross line boundaries
Bram Moolenaar <Bram@vim.org>
parents: 15138
diff changeset
516 bwipe!
15292
ba6f0f1bb9d0 patch 8.1.0654: when deleting a line text property flags are not adjusted
Bram Moolenaar <Bram@vim.org>
parents: 15269
diff changeset
517
15335
18c20ceee4b5 patch 8.1.0675: text property column in screen columns is not practical
Bram Moolenaar <Bram@vim.org>
parents: 15318
diff changeset
518 " Test deleting the first line of a multi-line prop.
15292
ba6f0f1bb9d0 patch 8.1.0654: when deleting a line text property flags are not adjusted
Bram Moolenaar <Bram@vim.org>
parents: 15269
diff changeset
519 call Setup_three_line_prop()
15335
18c20ceee4b5 patch 8.1.0675: text property column in screen columns is not practical
Bram Moolenaar <Bram@vim.org>
parents: 15318
diff changeset
520 let expect_short = {'col': 2, 'length': 1, 'type': 'comment', 'start': 1, 'end': 1, 'id': 0}
18c20ceee4b5 patch 8.1.0675: text property column in screen columns is not practical
Bram Moolenaar <Bram@vim.org>
parents: 15318
diff changeset
521 call assert_equal([expect_short], prop_list(1))
15292
ba6f0f1bb9d0 patch 8.1.0654: when deleting a line text property flags are not adjusted
Bram Moolenaar <Bram@vim.org>
parents: 15269
diff changeset
522 let expect2 = {'col': 4, 'length': 4, 'type': 'comment', 'start': 1, 'end': 0, 'id': 0}
ba6f0f1bb9d0 patch 8.1.0654: when deleting a line text property flags are not adjusted
Bram Moolenaar <Bram@vim.org>
parents: 15269
diff changeset
523 call assert_equal([expect2], prop_list(2))
ba6f0f1bb9d0 patch 8.1.0654: when deleting a line text property flags are not adjusted
Bram Moolenaar <Bram@vim.org>
parents: 15269
diff changeset
524 2del
ba6f0f1bb9d0 patch 8.1.0654: when deleting a line text property flags are not adjusted
Bram Moolenaar <Bram@vim.org>
parents: 15269
diff changeset
525 call assert_equal([expect_short], prop_list(1))
ba6f0f1bb9d0 patch 8.1.0654: when deleting a line text property flags are not adjusted
Bram Moolenaar <Bram@vim.org>
parents: 15269
diff changeset
526 let expect2 = {'col': 1, 'length': 6, 'type': 'comment', 'start': 1, 'end': 0, 'id': 0}
ba6f0f1bb9d0 patch 8.1.0654: when deleting a line text property flags are not adjusted
Bram Moolenaar <Bram@vim.org>
parents: 15269
diff changeset
527 call assert_equal([expect2], prop_list(2))
ba6f0f1bb9d0 patch 8.1.0654: when deleting a line text property flags are not adjusted
Bram Moolenaar <Bram@vim.org>
parents: 15269
diff changeset
528 bwipe!
ba6f0f1bb9d0 patch 8.1.0654: when deleting a line text property flags are not adjusted
Bram Moolenaar <Bram@vim.org>
parents: 15269
diff changeset
529
15335
18c20ceee4b5 patch 8.1.0675: text property column in screen columns is not practical
Bram Moolenaar <Bram@vim.org>
parents: 15318
diff changeset
530 " Test deleting the last line of a multi-line prop.
15292
ba6f0f1bb9d0 patch 8.1.0654: when deleting a line text property flags are not adjusted
Bram Moolenaar <Bram@vim.org>
parents: 15269
diff changeset
531 call Setup_three_line_prop()
ba6f0f1bb9d0 patch 8.1.0654: when deleting a line text property flags are not adjusted
Bram Moolenaar <Bram@vim.org>
parents: 15269
diff changeset
532 let expect3 = {'col': 1, 'length': 6, 'type': 'comment', 'start': 0, 'end': 0, 'id': 0}
ba6f0f1bb9d0 patch 8.1.0654: when deleting a line text property flags are not adjusted
Bram Moolenaar <Bram@vim.org>
parents: 15269
diff changeset
533 call assert_equal([expect3], prop_list(3))
15335
18c20ceee4b5 patch 8.1.0675: text property column in screen columns is not practical
Bram Moolenaar <Bram@vim.org>
parents: 15318
diff changeset
534 let expect4 = {'col': 1, 'length': 4, 'type': 'comment', 'start': 0, 'end': 1, 'id': 0}
15292
ba6f0f1bb9d0 patch 8.1.0654: when deleting a line text property flags are not adjusted
Bram Moolenaar <Bram@vim.org>
parents: 15269
diff changeset
535 call assert_equal([expect4], prop_list(4))
ba6f0f1bb9d0 patch 8.1.0654: when deleting a line text property flags are not adjusted
Bram Moolenaar <Bram@vim.org>
parents: 15269
diff changeset
536 4del
15335
18c20ceee4b5 patch 8.1.0675: text property column in screen columns is not practical
Bram Moolenaar <Bram@vim.org>
parents: 15318
diff changeset
537 let expect3.end = 1
15292
ba6f0f1bb9d0 patch 8.1.0654: when deleting a line text property flags are not adjusted
Bram Moolenaar <Bram@vim.org>
parents: 15269
diff changeset
538 call assert_equal([expect3], prop_list(3))
ba6f0f1bb9d0 patch 8.1.0654: when deleting a line text property flags are not adjusted
Bram Moolenaar <Bram@vim.org>
parents: 15269
diff changeset
539 call assert_equal([expect_short], prop_list(4))
ba6f0f1bb9d0 patch 8.1.0654: when deleting a line text property flags are not adjusted
Bram Moolenaar <Bram@vim.org>
parents: 15269
diff changeset
540 bwipe!
ba6f0f1bb9d0 patch 8.1.0654: when deleting a line text property flags are not adjusted
Bram Moolenaar <Bram@vim.org>
parents: 15269
diff changeset
541
15335
18c20ceee4b5 patch 8.1.0675: text property column in screen columns is not practical
Bram Moolenaar <Bram@vim.org>
parents: 15318
diff changeset
542 " Test appending a line below the multi-line text prop start.
15294
2d8225cc1315 patch 8.1.0655: when appending a line text property flags are not added
Bram Moolenaar <Bram@vim.org>
parents: 15292
diff changeset
543 call Setup_three_line_prop()
2d8225cc1315 patch 8.1.0655: when appending a line text property flags are not added
Bram Moolenaar <Bram@vim.org>
parents: 15292
diff changeset
544 let expect2 = {'col': 4, 'length': 4, 'type': 'comment', 'start': 1, 'end': 0, 'id': 0}
2d8225cc1315 patch 8.1.0655: when appending a line text property flags are not added
Bram Moolenaar <Bram@vim.org>
parents: 15292
diff changeset
545 call assert_equal([expect2], prop_list(2))
2d8225cc1315 patch 8.1.0655: when appending a line text property flags are not added
Bram Moolenaar <Bram@vim.org>
parents: 15292
diff changeset
546 call append(2, "new line")
2d8225cc1315 patch 8.1.0655: when appending a line text property flags are not added
Bram Moolenaar <Bram@vim.org>
parents: 15292
diff changeset
547 call assert_equal([expect2], prop_list(2))
2d8225cc1315 patch 8.1.0655: when appending a line text property flags are not added
Bram Moolenaar <Bram@vim.org>
parents: 15292
diff changeset
548 let expect3 = {'col': 1, 'length': 9, 'type': 'comment', 'start': 0, 'end': 0, 'id': 0}
2d8225cc1315 patch 8.1.0655: when appending a line text property flags are not added
Bram Moolenaar <Bram@vim.org>
parents: 15292
diff changeset
549 call assert_equal([expect3], prop_list(3))
2d8225cc1315 patch 8.1.0655: when appending a line text property flags are not added
Bram Moolenaar <Bram@vim.org>
parents: 15292
diff changeset
550 bwipe!
2d8225cc1315 patch 8.1.0655: when appending a line text property flags are not added
Bram Moolenaar <Bram@vim.org>
parents: 15292
diff changeset
551
15251
17525ca95e1e patch 8.1.0634: text properties cannot cross line boundaries
Bram Moolenaar <Bram@vim.org>
parents: 15138
diff changeset
552 call prop_type_delete('comment')
17525ca95e1e patch 8.1.0634: text properties cannot cross line boundaries
Bram Moolenaar <Bram@vim.org>
parents: 15138
diff changeset
553 endfunc
17525ca95e1e patch 8.1.0634: text properties cannot cross line boundaries
Bram Moolenaar <Bram@vim.org>
parents: 15138
diff changeset
554
15255
19e79a1ed6b6 patch 8.1.0636: line2byte() gives wrong values with text properties
Bram Moolenaar <Bram@vim.org>
parents: 15251
diff changeset
555 func Test_prop_byteoff()
19e79a1ed6b6 patch 8.1.0636: line2byte() gives wrong values with text properties
Bram Moolenaar <Bram@vim.org>
parents: 15251
diff changeset
556 call prop_type_add('comment', {'highlight': 'Directory'})
19e79a1ed6b6 patch 8.1.0636: line2byte() gives wrong values with text properties
Bram Moolenaar <Bram@vim.org>
parents: 15251
diff changeset
557 new
15269
27783a6f430b patch 8.1.0643: computing byte offset wrong
Bram Moolenaar <Bram@vim.org>
parents: 15261
diff changeset
558 call setline(1, ['line1', 'second line', ''])
15261
c5cb5151940d patch 8.1.0639: text properties test fails on MS-Windows
Bram Moolenaar <Bram@vim.org>
parents: 15255
diff changeset
559 set ff=unix
15269
27783a6f430b patch 8.1.0643: computing byte offset wrong
Bram Moolenaar <Bram@vim.org>
parents: 15261
diff changeset
560 call assert_equal(19, line2byte(3))
15255
19e79a1ed6b6 patch 8.1.0636: line2byte() gives wrong values with text properties
Bram Moolenaar <Bram@vim.org>
parents: 15251
diff changeset
561 call prop_add(1, 1, {'end_col': 3, 'type': 'comment'})
15269
27783a6f430b patch 8.1.0643: computing byte offset wrong
Bram Moolenaar <Bram@vim.org>
parents: 15261
diff changeset
562 call assert_equal(19, line2byte(3))
15255
19e79a1ed6b6 patch 8.1.0636: line2byte() gives wrong values with text properties
Bram Moolenaar <Bram@vim.org>
parents: 15251
diff changeset
563
19e79a1ed6b6 patch 8.1.0636: line2byte() gives wrong values with text properties
Bram Moolenaar <Bram@vim.org>
parents: 15251
diff changeset
564 bwipe!
19e79a1ed6b6 patch 8.1.0636: line2byte() gives wrong values with text properties
Bram Moolenaar <Bram@vim.org>
parents: 15251
diff changeset
565 call prop_type_delete('comment')
19e79a1ed6b6 patch 8.1.0636: line2byte() gives wrong values with text properties
Bram Moolenaar <Bram@vim.org>
parents: 15251
diff changeset
566 endfunc
19e79a1ed6b6 patch 8.1.0636: line2byte() gives wrong values with text properties
Bram Moolenaar <Bram@vim.org>
parents: 15251
diff changeset
567
15363
45f36b66a032 patch 8.1.0689: undo with text properties not tested
Bram Moolenaar <Bram@vim.org>
parents: 15349
diff changeset
568 func Test_prop_undo()
45f36b66a032 patch 8.1.0689: undo with text properties not tested
Bram Moolenaar <Bram@vim.org>
parents: 15349
diff changeset
569 new
45f36b66a032 patch 8.1.0689: undo with text properties not tested
Bram Moolenaar <Bram@vim.org>
parents: 15349
diff changeset
570 call prop_type_add('comment', {'highlight': 'Directory'})
45f36b66a032 patch 8.1.0689: undo with text properties not tested
Bram Moolenaar <Bram@vim.org>
parents: 15349
diff changeset
571 call setline(1, ['oneone', 'twotwo', 'three'])
45f36b66a032 patch 8.1.0689: undo with text properties not tested
Bram Moolenaar <Bram@vim.org>
parents: 15349
diff changeset
572 " Set 'undolevels' to break changes into undo-able pieces.
45f36b66a032 patch 8.1.0689: undo with text properties not tested
Bram Moolenaar <Bram@vim.org>
parents: 15349
diff changeset
573 set ul&
45f36b66a032 patch 8.1.0689: undo with text properties not tested
Bram Moolenaar <Bram@vim.org>
parents: 15349
diff changeset
574
45f36b66a032 patch 8.1.0689: undo with text properties not tested
Bram Moolenaar <Bram@vim.org>
parents: 15349
diff changeset
575 call prop_add(1, 3, {'end_col': 5, 'type': 'comment'})
45f36b66a032 patch 8.1.0689: undo with text properties not tested
Bram Moolenaar <Bram@vim.org>
parents: 15349
diff changeset
576 let expected = [{'col': 3, 'length': 2, 'id': 0, 'type': 'comment', 'start': 1, 'end': 1} ]
45f36b66a032 patch 8.1.0689: undo with text properties not tested
Bram Moolenaar <Bram@vim.org>
parents: 15349
diff changeset
577 call assert_equal(expected, prop_list(1))
45f36b66a032 patch 8.1.0689: undo with text properties not tested
Bram Moolenaar <Bram@vim.org>
parents: 15349
diff changeset
578
45f36b66a032 patch 8.1.0689: undo with text properties not tested
Bram Moolenaar <Bram@vim.org>
parents: 15349
diff changeset
579 " Insert a character, then undo.
45f36b66a032 patch 8.1.0689: undo with text properties not tested
Bram Moolenaar <Bram@vim.org>
parents: 15349
diff changeset
580 exe "normal 0lllix\<Esc>"
45f36b66a032 patch 8.1.0689: undo with text properties not tested
Bram Moolenaar <Bram@vim.org>
parents: 15349
diff changeset
581 set ul&
45f36b66a032 patch 8.1.0689: undo with text properties not tested
Bram Moolenaar <Bram@vim.org>
parents: 15349
diff changeset
582 let expected[0].length = 3
45f36b66a032 patch 8.1.0689: undo with text properties not tested
Bram Moolenaar <Bram@vim.org>
parents: 15349
diff changeset
583 call assert_equal(expected, prop_list(1))
45f36b66a032 patch 8.1.0689: undo with text properties not tested
Bram Moolenaar <Bram@vim.org>
parents: 15349
diff changeset
584 undo
45f36b66a032 patch 8.1.0689: undo with text properties not tested
Bram Moolenaar <Bram@vim.org>
parents: 15349
diff changeset
585 let expected[0].length = 2
45f36b66a032 patch 8.1.0689: undo with text properties not tested
Bram Moolenaar <Bram@vim.org>
parents: 15349
diff changeset
586 call assert_equal(expected, prop_list(1))
45f36b66a032 patch 8.1.0689: undo with text properties not tested
Bram Moolenaar <Bram@vim.org>
parents: 15349
diff changeset
587
45f36b66a032 patch 8.1.0689: undo with text properties not tested
Bram Moolenaar <Bram@vim.org>
parents: 15349
diff changeset
588 " Delete a character, then undo
45f36b66a032 patch 8.1.0689: undo with text properties not tested
Bram Moolenaar <Bram@vim.org>
parents: 15349
diff changeset
589 exe "normal 0lllx"
45f36b66a032 patch 8.1.0689: undo with text properties not tested
Bram Moolenaar <Bram@vim.org>
parents: 15349
diff changeset
590 set ul&
45f36b66a032 patch 8.1.0689: undo with text properties not tested
Bram Moolenaar <Bram@vim.org>
parents: 15349
diff changeset
591 let expected[0].length = 1
45f36b66a032 patch 8.1.0689: undo with text properties not tested
Bram Moolenaar <Bram@vim.org>
parents: 15349
diff changeset
592 call assert_equal(expected, prop_list(1))
45f36b66a032 patch 8.1.0689: undo with text properties not tested
Bram Moolenaar <Bram@vim.org>
parents: 15349
diff changeset
593 undo
45f36b66a032 patch 8.1.0689: undo with text properties not tested
Bram Moolenaar <Bram@vim.org>
parents: 15349
diff changeset
594 let expected[0].length = 2
45f36b66a032 patch 8.1.0689: undo with text properties not tested
Bram Moolenaar <Bram@vim.org>
parents: 15349
diff changeset
595 call assert_equal(expected, prop_list(1))
45f36b66a032 patch 8.1.0689: undo with text properties not tested
Bram Moolenaar <Bram@vim.org>
parents: 15349
diff changeset
596
45f36b66a032 patch 8.1.0689: undo with text properties not tested
Bram Moolenaar <Bram@vim.org>
parents: 15349
diff changeset
597 " Delete the line, then undo
45f36b66a032 patch 8.1.0689: undo with text properties not tested
Bram Moolenaar <Bram@vim.org>
parents: 15349
diff changeset
598 1d
45f36b66a032 patch 8.1.0689: undo with text properties not tested
Bram Moolenaar <Bram@vim.org>
parents: 15349
diff changeset
599 set ul&
45f36b66a032 patch 8.1.0689: undo with text properties not tested
Bram Moolenaar <Bram@vim.org>
parents: 15349
diff changeset
600 call assert_equal([], prop_list(1))
45f36b66a032 patch 8.1.0689: undo with text properties not tested
Bram Moolenaar <Bram@vim.org>
parents: 15349
diff changeset
601 undo
45f36b66a032 patch 8.1.0689: undo with text properties not tested
Bram Moolenaar <Bram@vim.org>
parents: 15349
diff changeset
602 call assert_equal(expected, prop_list(1))
45f36b66a032 patch 8.1.0689: undo with text properties not tested
Bram Moolenaar <Bram@vim.org>
parents: 15349
diff changeset
603
45f36b66a032 patch 8.1.0689: undo with text properties not tested
Bram Moolenaar <Bram@vim.org>
parents: 15349
diff changeset
604 " Insert a character, delete two characters, then undo with "U"
45f36b66a032 patch 8.1.0689: undo with text properties not tested
Bram Moolenaar <Bram@vim.org>
parents: 15349
diff changeset
605 exe "normal 0lllix\<Esc>"
45f36b66a032 patch 8.1.0689: undo with text properties not tested
Bram Moolenaar <Bram@vim.org>
parents: 15349
diff changeset
606 set ul&
45f36b66a032 patch 8.1.0689: undo with text properties not tested
Bram Moolenaar <Bram@vim.org>
parents: 15349
diff changeset
607 let expected[0].length = 3
45f36b66a032 patch 8.1.0689: undo with text properties not tested
Bram Moolenaar <Bram@vim.org>
parents: 15349
diff changeset
608 call assert_equal(expected, prop_list(1))
45f36b66a032 patch 8.1.0689: undo with text properties not tested
Bram Moolenaar <Bram@vim.org>
parents: 15349
diff changeset
609 exe "normal 0lllxx"
45f36b66a032 patch 8.1.0689: undo with text properties not tested
Bram Moolenaar <Bram@vim.org>
parents: 15349
diff changeset
610 set ul&
45f36b66a032 patch 8.1.0689: undo with text properties not tested
Bram Moolenaar <Bram@vim.org>
parents: 15349
diff changeset
611 let expected[0].length = 1
45f36b66a032 patch 8.1.0689: undo with text properties not tested
Bram Moolenaar <Bram@vim.org>
parents: 15349
diff changeset
612 call assert_equal(expected, prop_list(1))
45f36b66a032 patch 8.1.0689: undo with text properties not tested
Bram Moolenaar <Bram@vim.org>
parents: 15349
diff changeset
613 normal U
45f36b66a032 patch 8.1.0689: undo with text properties not tested
Bram Moolenaar <Bram@vim.org>
parents: 15349
diff changeset
614 let expected[0].length = 2
45f36b66a032 patch 8.1.0689: undo with text properties not tested
Bram Moolenaar <Bram@vim.org>
parents: 15349
diff changeset
615 call assert_equal(expected, prop_list(1))
45f36b66a032 patch 8.1.0689: undo with text properties not tested
Bram Moolenaar <Bram@vim.org>
parents: 15349
diff changeset
616
16698
23af483c4ceb patch 8.1.1351: text property wrong after :substitute
Bram Moolenaar <Bram@vim.org>
parents: 16682
diff changeset
617 " substitute a word, then undo
23af483c4ceb patch 8.1.1351: text property wrong after :substitute
Bram Moolenaar <Bram@vim.org>
parents: 16682
diff changeset
618 call setline(1, 'the number 123 is highlighted.')
23af483c4ceb patch 8.1.1351: text property wrong after :substitute
Bram Moolenaar <Bram@vim.org>
parents: 16682
diff changeset
619 call prop_add(1, 12, {'length': 3, 'type': 'comment'})
23af483c4ceb patch 8.1.1351: text property wrong after :substitute
Bram Moolenaar <Bram@vim.org>
parents: 16682
diff changeset
620 let expected = [{'col': 12, 'length': 3, 'id': 0, 'type': 'comment', 'start': 1, 'end': 1} ]
23af483c4ceb patch 8.1.1351: text property wrong after :substitute
Bram Moolenaar <Bram@vim.org>
parents: 16682
diff changeset
621 call assert_equal(expected, prop_list(1))
23af483c4ceb patch 8.1.1351: text property wrong after :substitute
Bram Moolenaar <Bram@vim.org>
parents: 16682
diff changeset
622 set ul&
23af483c4ceb patch 8.1.1351: text property wrong after :substitute
Bram Moolenaar <Bram@vim.org>
parents: 16682
diff changeset
623 1s/number/foo
23af483c4ceb patch 8.1.1351: text property wrong after :substitute
Bram Moolenaar <Bram@vim.org>
parents: 16682
diff changeset
624 let expected[0].col = 9
23af483c4ceb patch 8.1.1351: text property wrong after :substitute
Bram Moolenaar <Bram@vim.org>
parents: 16682
diff changeset
625 call assert_equal(expected, prop_list(1))
23af483c4ceb patch 8.1.1351: text property wrong after :substitute
Bram Moolenaar <Bram@vim.org>
parents: 16682
diff changeset
626 undo
23af483c4ceb patch 8.1.1351: text property wrong after :substitute
Bram Moolenaar <Bram@vim.org>
parents: 16682
diff changeset
627 let expected[0].col = 12
23af483c4ceb patch 8.1.1351: text property wrong after :substitute
Bram Moolenaar <Bram@vim.org>
parents: 16682
diff changeset
628 call assert_equal(expected, prop_list(1))
16714
ba592f30c082 patch 8.1.1359: text property wrong after :substitute with backslash
Bram Moolenaar <Bram@vim.org>
parents: 16698
diff changeset
629 call prop_clear(1)
ba592f30c082 patch 8.1.1359: text property wrong after :substitute with backslash
Bram Moolenaar <Bram@vim.org>
parents: 16698
diff changeset
630
ba592f30c082 patch 8.1.1359: text property wrong after :substitute with backslash
Bram Moolenaar <Bram@vim.org>
parents: 16698
diff changeset
631 " substitute with backslash
ba592f30c082 patch 8.1.1359: text property wrong after :substitute with backslash
Bram Moolenaar <Bram@vim.org>
parents: 16698
diff changeset
632 call setline(1, 'the number 123 is highlighted.')
ba592f30c082 patch 8.1.1359: text property wrong after :substitute with backslash
Bram Moolenaar <Bram@vim.org>
parents: 16698
diff changeset
633 call prop_add(1, 12, {'length': 3, 'type': 'comment'})
ba592f30c082 patch 8.1.1359: text property wrong after :substitute with backslash
Bram Moolenaar <Bram@vim.org>
parents: 16698
diff changeset
634 let expected = [{'col': 12, 'length': 3, 'id': 0, 'type': 'comment', 'start': 1, 'end': 1} ]
ba592f30c082 patch 8.1.1359: text property wrong after :substitute with backslash
Bram Moolenaar <Bram@vim.org>
parents: 16698
diff changeset
635 call assert_equal(expected, prop_list(1))
ba592f30c082 patch 8.1.1359: text property wrong after :substitute with backslash
Bram Moolenaar <Bram@vim.org>
parents: 16698
diff changeset
636 1s/the/\The
ba592f30c082 patch 8.1.1359: text property wrong after :substitute with backslash
Bram Moolenaar <Bram@vim.org>
parents: 16698
diff changeset
637 call assert_equal(expected, prop_list(1))
ba592f30c082 patch 8.1.1359: text property wrong after :substitute with backslash
Bram Moolenaar <Bram@vim.org>
parents: 16698
diff changeset
638 1s/^/\\
ba592f30c082 patch 8.1.1359: text property wrong after :substitute with backslash
Bram Moolenaar <Bram@vim.org>
parents: 16698
diff changeset
639 let expected[0].col += 1
ba592f30c082 patch 8.1.1359: text property wrong after :substitute with backslash
Bram Moolenaar <Bram@vim.org>
parents: 16698
diff changeset
640 call assert_equal(expected, prop_list(1))
ba592f30c082 patch 8.1.1359: text property wrong after :substitute with backslash
Bram Moolenaar <Bram@vim.org>
parents: 16698
diff changeset
641 1s/^/\~
ba592f30c082 patch 8.1.1359: text property wrong after :substitute with backslash
Bram Moolenaar <Bram@vim.org>
parents: 16698
diff changeset
642 let expected[0].col += 1
ba592f30c082 patch 8.1.1359: text property wrong after :substitute with backslash
Bram Moolenaar <Bram@vim.org>
parents: 16698
diff changeset
643 call assert_equal(expected, prop_list(1))
ba592f30c082 patch 8.1.1359: text property wrong after :substitute with backslash
Bram Moolenaar <Bram@vim.org>
parents: 16698
diff changeset
644 1s/123/12\\3
ba592f30c082 patch 8.1.1359: text property wrong after :substitute with backslash
Bram Moolenaar <Bram@vim.org>
parents: 16698
diff changeset
645 let expected[0].length += 1
ba592f30c082 patch 8.1.1359: text property wrong after :substitute with backslash
Bram Moolenaar <Bram@vim.org>
parents: 16698
diff changeset
646 call assert_equal(expected, prop_list(1))
ba592f30c082 patch 8.1.1359: text property wrong after :substitute with backslash
Bram Moolenaar <Bram@vim.org>
parents: 16698
diff changeset
647 call prop_clear(1)
16698
23af483c4ceb patch 8.1.1351: text property wrong after :substitute
Bram Moolenaar <Bram@vim.org>
parents: 16682
diff changeset
648
15363
45f36b66a032 patch 8.1.0689: undo with text properties not tested
Bram Moolenaar <Bram@vim.org>
parents: 15349
diff changeset
649 bwipe!
45f36b66a032 patch 8.1.0689: undo with text properties not tested
Bram Moolenaar <Bram@vim.org>
parents: 15349
diff changeset
650 call prop_type_delete('comment')
45f36b66a032 patch 8.1.0689: undo with text properties not tested
Bram Moolenaar <Bram@vim.org>
parents: 15349
diff changeset
651 endfunc
45f36b66a032 patch 8.1.0689: undo with text properties not tested
Bram Moolenaar <Bram@vim.org>
parents: 15349
diff changeset
652
15314
c4d62945d96f patch 8.1.0665: text property display wrong when 'spell' is set
Bram Moolenaar <Bram@vim.org>
parents: 15294
diff changeset
653 " screenshot test with textprop highlighting
16682
7847d281cbbf patch 8.1.1343: text properties not adjusted for Visual block mode delete
Bram Moolenaar <Bram@vim.org>
parents: 16678
diff changeset
654 func Test_textprop_screenshot_various()
18317
d2228d4cf1f6 patch 8.1.2153: combining text property and syntax highlight is wrong
Bram Moolenaar <Bram@vim.org>
parents: 17980
diff changeset
655 CheckScreendump
15928
857ce36c8412 patch 8.1.0970: text properties test fails when 'encoding' is not utf-8
Bram Moolenaar <Bram@vim.org>
parents: 15398
diff changeset
656 " The Vim running in the terminal needs to use utf-8.
18317
d2228d4cf1f6 patch 8.1.2153: combining text property and syntax highlight is wrong
Bram Moolenaar <Bram@vim.org>
parents: 17980
diff changeset
657 if g:orig_encoding != 'utf-8'
d2228d4cf1f6 patch 8.1.2153: combining text property and syntax highlight is wrong
Bram Moolenaar <Bram@vim.org>
parents: 17980
diff changeset
658 throw 'Skipped: not using utf-8'
15314
c4d62945d96f patch 8.1.0665: text property display wrong when 'spell' is set
Bram Moolenaar <Bram@vim.org>
parents: 15294
diff changeset
659 endif
c4d62945d96f patch 8.1.0665: text property display wrong when 'spell' is set
Bram Moolenaar <Bram@vim.org>
parents: 15294
diff changeset
660 call writefile([
16545
7a563ee902b6 patch 8.1.1276: cannot combine text properties with syntax highlighting
Bram Moolenaar <Bram@vim.org>
parents: 16060
diff changeset
661 \ "call setline(1, ["
7a563ee902b6 patch 8.1.1276: cannot combine text properties with syntax highlighting
Bram Moolenaar <Bram@vim.org>
parents: 16060
diff changeset
662 \ .. "'One two',"
7a563ee902b6 patch 8.1.1276: cannot combine text properties with syntax highlighting
Bram Moolenaar <Bram@vim.org>
parents: 16060
diff changeset
663 \ .. "'Numbér 123 änd thœn 4¾7.',"
7a563ee902b6 patch 8.1.1276: cannot combine text properties with syntax highlighting
Bram Moolenaar <Bram@vim.org>
parents: 16060
diff changeset
664 \ .. "'--aa--bb--cc--dd--',"
7a563ee902b6 patch 8.1.1276: cannot combine text properties with syntax highlighting
Bram Moolenaar <Bram@vim.org>
parents: 16060
diff changeset
665 \ .. "'// comment with error in it',"
16678
6f453673eb19 patch 8.1.1341: text properties are lost when joining lines
Bram Moolenaar <Bram@vim.org>
parents: 16676
diff changeset
666 \ .. "'first line',"
6f453673eb19 patch 8.1.1341: text properties are lost when joining lines
Bram Moolenaar <Bram@vim.org>
parents: 16676
diff changeset
667 \ .. "' second line ',"
6f453673eb19 patch 8.1.1341: text properties are lost when joining lines
Bram Moolenaar <Bram@vim.org>
parents: 16676
diff changeset
668 \ .. "'third line',"
6f453673eb19 patch 8.1.1341: text properties are lost when joining lines
Bram Moolenaar <Bram@vim.org>
parents: 16676
diff changeset
669 \ .. "' fourth line',"
16545
7a563ee902b6 patch 8.1.1276: cannot combine text properties with syntax highlighting
Bram Moolenaar <Bram@vim.org>
parents: 16060
diff changeset
670 \ .. "])",
15314
c4d62945d96f patch 8.1.0665: text property display wrong when 'spell' is set
Bram Moolenaar <Bram@vim.org>
parents: 15294
diff changeset
671 \ "hi NumberProp ctermfg=blue",
c4d62945d96f patch 8.1.0665: text property display wrong when 'spell' is set
Bram Moolenaar <Bram@vim.org>
parents: 15294
diff changeset
672 \ "hi LongProp ctermbg=yellow",
16545
7a563ee902b6 patch 8.1.1276: cannot combine text properties with syntax highlighting
Bram Moolenaar <Bram@vim.org>
parents: 16060
diff changeset
673 \ "hi BackgroundProp ctermbg=lightgrey",
7a563ee902b6 patch 8.1.1276: cannot combine text properties with syntax highlighting
Bram Moolenaar <Bram@vim.org>
parents: 16060
diff changeset
674 \ "hi UnderlineProp cterm=underline",
15314
c4d62945d96f patch 8.1.0665: text property display wrong when 'spell' is set
Bram Moolenaar <Bram@vim.org>
parents: 15294
diff changeset
675 \ "call prop_type_add('number', {'highlight': 'NumberProp'})",
17980
52f23198af7f patch 8.1.1986: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17694
diff changeset
676 \ "call prop_type_add('long', {'highlight': 'NumberProp'})",
52f23198af7f patch 8.1.1986: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17694
diff changeset
677 \ "call prop_type_change('long', {'highlight': 'LongProp'})",
15341
03a7a9fdb792 patch 8.1.0678: text properties as not adjusted for inserted text
Bram Moolenaar <Bram@vim.org>
parents: 15335
diff changeset
678 \ "call prop_type_add('start', {'highlight': 'NumberProp', 'start_incl': 1})",
03a7a9fdb792 patch 8.1.0678: text properties as not adjusted for inserted text
Bram Moolenaar <Bram@vim.org>
parents: 15335
diff changeset
679 \ "call prop_type_add('end', {'highlight': 'NumberProp', 'end_incl': 1})",
03a7a9fdb792 patch 8.1.0678: text properties as not adjusted for inserted text
Bram Moolenaar <Bram@vim.org>
parents: 15335
diff changeset
680 \ "call prop_type_add('both', {'highlight': 'NumberProp', 'start_incl': 1, 'end_incl': 1})",
17980
52f23198af7f patch 8.1.1986: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17694
diff changeset
681 \ "call prop_type_add('background', {'highlight': 'NumberProp', 'combine': 1})",
52f23198af7f patch 8.1.1986: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17694
diff changeset
682 \ "eval 'background'->prop_type_change({'highlight': 'BackgroundProp'})",
16545
7a563ee902b6 patch 8.1.1276: cannot combine text properties with syntax highlighting
Bram Moolenaar <Bram@vim.org>
parents: 16060
diff changeset
683 \ "call prop_type_add('error', {'highlight': 'UnderlineProp', 'combine': 1})",
15314
c4d62945d96f patch 8.1.0665: text property display wrong when 'spell' is set
Bram Moolenaar <Bram@vim.org>
parents: 15294
diff changeset
684 \ "call prop_add(1, 4, {'end_lnum': 3, 'end_col': 3, 'type': 'long'})",
15335
18c20ceee4b5 patch 8.1.0675: text property column in screen columns is not practical
Bram Moolenaar <Bram@vim.org>
parents: 15318
diff changeset
685 \ "call prop_add(2, 9, {'length': 3, 'type': 'number'})",
18c20ceee4b5 patch 8.1.0675: text property column in screen columns is not practical
Bram Moolenaar <Bram@vim.org>
parents: 15318
diff changeset
686 \ "call prop_add(2, 24, {'length': 4, 'type': 'number'})",
15341
03a7a9fdb792 patch 8.1.0678: text properties as not adjusted for inserted text
Bram Moolenaar <Bram@vim.org>
parents: 15335
diff changeset
687 \ "call prop_add(3, 3, {'length': 2, 'type': 'number'})",
03a7a9fdb792 patch 8.1.0678: text properties as not adjusted for inserted text
Bram Moolenaar <Bram@vim.org>
parents: 15335
diff changeset
688 \ "call prop_add(3, 7, {'length': 2, 'type': 'start'})",
03a7a9fdb792 patch 8.1.0678: text properties as not adjusted for inserted text
Bram Moolenaar <Bram@vim.org>
parents: 15335
diff changeset
689 \ "call prop_add(3, 11, {'length': 2, 'type': 'end'})",
03a7a9fdb792 patch 8.1.0678: text properties as not adjusted for inserted text
Bram Moolenaar <Bram@vim.org>
parents: 15335
diff changeset
690 \ "call prop_add(3, 15, {'length': 2, 'type': 'both'})",
16545
7a563ee902b6 patch 8.1.1276: cannot combine text properties with syntax highlighting
Bram Moolenaar <Bram@vim.org>
parents: 16060
diff changeset
691 \ "call prop_add(4, 12, {'length': 10, 'type': 'background'})",
7a563ee902b6 patch 8.1.1276: cannot combine text properties with syntax highlighting
Bram Moolenaar <Bram@vim.org>
parents: 16060
diff changeset
692 \ "call prop_add(4, 17, {'length': 5, 'type': 'error'})",
16678
6f453673eb19 patch 8.1.1341: text properties are lost when joining lines
Bram Moolenaar <Bram@vim.org>
parents: 16676
diff changeset
693 \ "call prop_add(5, 7, {'length': 4, 'type': 'long'})",
6f453673eb19 patch 8.1.1341: text properties are lost when joining lines
Bram Moolenaar <Bram@vim.org>
parents: 16676
diff changeset
694 \ "call prop_add(6, 1, {'length': 8, 'type': 'long'})",
6f453673eb19 patch 8.1.1341: text properties are lost when joining lines
Bram Moolenaar <Bram@vim.org>
parents: 16676
diff changeset
695 \ "call prop_add(8, 1, {'length': 1, 'type': 'long'})",
6f453673eb19 patch 8.1.1341: text properties are lost when joining lines
Bram Moolenaar <Bram@vim.org>
parents: 16676
diff changeset
696 \ "call prop_add(8, 11, {'length': 4, 'type': 'long'})",
16676
79c5f723bb5d patch 8.1.1340: attributes from 'cursorline' overwrite textprop
Bram Moolenaar <Bram@vim.org>
parents: 16670
diff changeset
697 \ "set number cursorline",
15335
18c20ceee4b5 patch 8.1.0675: text property column in screen columns is not practical
Bram Moolenaar <Bram@vim.org>
parents: 15318
diff changeset
698 \ "hi clear SpellBad",
15314
c4d62945d96f patch 8.1.0665: text property display wrong when 'spell' is set
Bram Moolenaar <Bram@vim.org>
parents: 15294
diff changeset
699 \ "set spell",
16545
7a563ee902b6 patch 8.1.1276: cannot combine text properties with syntax highlighting
Bram Moolenaar <Bram@vim.org>
parents: 16060
diff changeset
700 \ "syn match Comment '//.*'",
7a563ee902b6 patch 8.1.1276: cannot combine text properties with syntax highlighting
Bram Moolenaar <Bram@vim.org>
parents: 16060
diff changeset
701 \ "hi Comment ctermfg=green",
15341
03a7a9fdb792 patch 8.1.0678: text properties as not adjusted for inserted text
Bram Moolenaar <Bram@vim.org>
parents: 15335
diff changeset
702 \ "normal 3G0llix\<Esc>lllix\<Esc>lllix\<Esc>lllix\<Esc>lllix\<Esc>lllix\<Esc>lllix\<Esc>lllix\<Esc>",
15347
f6b522596993 patch 8.1.0681: text properties as not adjusted for deleted text
Bram Moolenaar <Bram@vim.org>
parents: 15341
diff changeset
703 \ "normal 3G0lli\<BS>\<Esc>",
16678
6f453673eb19 patch 8.1.1341: text properties are lost when joining lines
Bram Moolenaar <Bram@vim.org>
parents: 16676
diff changeset
704 \ "normal 6G0i\<BS>\<Esc>",
6f453673eb19 patch 8.1.1341: text properties are lost when joining lines
Bram Moolenaar <Bram@vim.org>
parents: 16676
diff changeset
705 \ "normal 3J",
6f453673eb19 patch 8.1.1341: text properties are lost when joining lines
Bram Moolenaar <Bram@vim.org>
parents: 16676
diff changeset
706 \ "normal 3G",
15314
c4d62945d96f patch 8.1.0665: text property display wrong when 'spell' is set
Bram Moolenaar <Bram@vim.org>
parents: 15294
diff changeset
707 \], 'XtestProp')
16678
6f453673eb19 patch 8.1.1341: text properties are lost when joining lines
Bram Moolenaar <Bram@vim.org>
parents: 16676
diff changeset
708 let buf = RunVimInTerminal('-S XtestProp', {'rows': 8})
15314
c4d62945d96f patch 8.1.0665: text property display wrong when 'spell' is set
Bram Moolenaar <Bram@vim.org>
parents: 15294
diff changeset
709 call VerifyScreenDump(buf, 'Test_textprop_01', {})
15251
17525ca95e1e patch 8.1.0634: text properties cannot cross line boundaries
Bram Moolenaar <Bram@vim.org>
parents: 15138
diff changeset
710
15314
c4d62945d96f patch 8.1.0665: text property display wrong when 'spell' is set
Bram Moolenaar <Bram@vim.org>
parents: 15294
diff changeset
711 " clean up
c4d62945d96f patch 8.1.0665: text property display wrong when 'spell' is set
Bram Moolenaar <Bram@vim.org>
parents: 15294
diff changeset
712 call StopVimInTerminal(buf)
15318
f58e7895cb40 patch 8.1.0667: textprop test leaves file behind
Bram Moolenaar <Bram@vim.org>
parents: 15314
diff changeset
713 call delete('XtestProp')
15314
c4d62945d96f patch 8.1.0665: text property display wrong when 'spell' is set
Bram Moolenaar <Bram@vim.org>
parents: 15294
diff changeset
714 endfunc
16682
7847d281cbbf patch 8.1.1343: text properties not adjusted for Visual block mode delete
Bram Moolenaar <Bram@vim.org>
parents: 16678
diff changeset
715
7847d281cbbf patch 8.1.1343: text properties not adjusted for Visual block mode delete
Bram Moolenaar <Bram@vim.org>
parents: 16678
diff changeset
716 func RunTestVisualBlock(width, dump)
7847d281cbbf patch 8.1.1343: text properties not adjusted for Visual block mode delete
Bram Moolenaar <Bram@vim.org>
parents: 16678
diff changeset
717 call writefile([
7847d281cbbf patch 8.1.1343: text properties not adjusted for Visual block mode delete
Bram Moolenaar <Bram@vim.org>
parents: 16678
diff changeset
718 \ "call setline(1, ["
7847d281cbbf patch 8.1.1343: text properties not adjusted for Visual block mode delete
Bram Moolenaar <Bram@vim.org>
parents: 16678
diff changeset
719 \ .. "'xxxxxxxxx 123 x',"
7847d281cbbf patch 8.1.1343: text properties not adjusted for Visual block mode delete
Bram Moolenaar <Bram@vim.org>
parents: 16678
diff changeset
720 \ .. "'xxxxxxxx 123 x',"
7847d281cbbf patch 8.1.1343: text properties not adjusted for Visual block mode delete
Bram Moolenaar <Bram@vim.org>
parents: 16678
diff changeset
721 \ .. "'xxxxxxx 123 x',"
7847d281cbbf patch 8.1.1343: text properties not adjusted for Visual block mode delete
Bram Moolenaar <Bram@vim.org>
parents: 16678
diff changeset
722 \ .. "'xxxxxx 123 x',"
7847d281cbbf patch 8.1.1343: text properties not adjusted for Visual block mode delete
Bram Moolenaar <Bram@vim.org>
parents: 16678
diff changeset
723 \ .. "'xxxxx 123 x',"
7847d281cbbf patch 8.1.1343: text properties not adjusted for Visual block mode delete
Bram Moolenaar <Bram@vim.org>
parents: 16678
diff changeset
724 \ .. "'xxxx 123 xx',"
7847d281cbbf patch 8.1.1343: text properties not adjusted for Visual block mode delete
Bram Moolenaar <Bram@vim.org>
parents: 16678
diff changeset
725 \ .. "'xxx 123 xxx',"
7847d281cbbf patch 8.1.1343: text properties not adjusted for Visual block mode delete
Bram Moolenaar <Bram@vim.org>
parents: 16678
diff changeset
726 \ .. "'xx 123 xxxx',"
7847d281cbbf patch 8.1.1343: text properties not adjusted for Visual block mode delete
Bram Moolenaar <Bram@vim.org>
parents: 16678
diff changeset
727 \ .. "'x 123 xxxxx',"
7847d281cbbf patch 8.1.1343: text properties not adjusted for Visual block mode delete
Bram Moolenaar <Bram@vim.org>
parents: 16678
diff changeset
728 \ .. "' 123 xxxxxx',"
7847d281cbbf patch 8.1.1343: text properties not adjusted for Visual block mode delete
Bram Moolenaar <Bram@vim.org>
parents: 16678
diff changeset
729 \ .. "])",
7847d281cbbf patch 8.1.1343: text properties not adjusted for Visual block mode delete
Bram Moolenaar <Bram@vim.org>
parents: 16678
diff changeset
730 \ "hi SearchProp ctermbg=yellow",
7847d281cbbf patch 8.1.1343: text properties not adjusted for Visual block mode delete
Bram Moolenaar <Bram@vim.org>
parents: 16678
diff changeset
731 \ "call prop_type_add('search', {'highlight': 'SearchProp'})",
7847d281cbbf patch 8.1.1343: text properties not adjusted for Visual block mode delete
Bram Moolenaar <Bram@vim.org>
parents: 16678
diff changeset
732 \ "call prop_add(1, 11, {'length': 3, 'type': 'search'})",
7847d281cbbf patch 8.1.1343: text properties not adjusted for Visual block mode delete
Bram Moolenaar <Bram@vim.org>
parents: 16678
diff changeset
733 \ "call prop_add(2, 10, {'length': 3, 'type': 'search'})",
7847d281cbbf patch 8.1.1343: text properties not adjusted for Visual block mode delete
Bram Moolenaar <Bram@vim.org>
parents: 16678
diff changeset
734 \ "call prop_add(3, 9, {'length': 3, 'type': 'search'})",
7847d281cbbf patch 8.1.1343: text properties not adjusted for Visual block mode delete
Bram Moolenaar <Bram@vim.org>
parents: 16678
diff changeset
735 \ "call prop_add(4, 8, {'length': 3, 'type': 'search'})",
7847d281cbbf patch 8.1.1343: text properties not adjusted for Visual block mode delete
Bram Moolenaar <Bram@vim.org>
parents: 16678
diff changeset
736 \ "call prop_add(5, 7, {'length': 3, 'type': 'search'})",
7847d281cbbf patch 8.1.1343: text properties not adjusted for Visual block mode delete
Bram Moolenaar <Bram@vim.org>
parents: 16678
diff changeset
737 \ "call prop_add(6, 6, {'length': 3, 'type': 'search'})",
7847d281cbbf patch 8.1.1343: text properties not adjusted for Visual block mode delete
Bram Moolenaar <Bram@vim.org>
parents: 16678
diff changeset
738 \ "call prop_add(7, 5, {'length': 3, 'type': 'search'})",
7847d281cbbf patch 8.1.1343: text properties not adjusted for Visual block mode delete
Bram Moolenaar <Bram@vim.org>
parents: 16678
diff changeset
739 \ "call prop_add(8, 4, {'length': 3, 'type': 'search'})",
7847d281cbbf patch 8.1.1343: text properties not adjusted for Visual block mode delete
Bram Moolenaar <Bram@vim.org>
parents: 16678
diff changeset
740 \ "call prop_add(9, 3, {'length': 3, 'type': 'search'})",
7847d281cbbf patch 8.1.1343: text properties not adjusted for Visual block mode delete
Bram Moolenaar <Bram@vim.org>
parents: 16678
diff changeset
741 \ "call prop_add(10, 2, {'length': 3, 'type': 'search'})",
7847d281cbbf patch 8.1.1343: text properties not adjusted for Visual block mode delete
Bram Moolenaar <Bram@vim.org>
parents: 16678
diff changeset
742 \ "normal 1G6|\<C-V>" .. repeat('l', a:width - 1) .. "10jx",
7847d281cbbf patch 8.1.1343: text properties not adjusted for Visual block mode delete
Bram Moolenaar <Bram@vim.org>
parents: 16678
diff changeset
743 \], 'XtestPropVis')
7847d281cbbf patch 8.1.1343: text properties not adjusted for Visual block mode delete
Bram Moolenaar <Bram@vim.org>
parents: 16678
diff changeset
744 let buf = RunVimInTerminal('-S XtestPropVis', {'rows': 12})
7847d281cbbf patch 8.1.1343: text properties not adjusted for Visual block mode delete
Bram Moolenaar <Bram@vim.org>
parents: 16678
diff changeset
745 call VerifyScreenDump(buf, 'Test_textprop_vis_' .. a:dump, {})
7847d281cbbf patch 8.1.1343: text properties not adjusted for Visual block mode delete
Bram Moolenaar <Bram@vim.org>
parents: 16678
diff changeset
746
7847d281cbbf patch 8.1.1343: text properties not adjusted for Visual block mode delete
Bram Moolenaar <Bram@vim.org>
parents: 16678
diff changeset
747 " clean up
7847d281cbbf patch 8.1.1343: text properties not adjusted for Visual block mode delete
Bram Moolenaar <Bram@vim.org>
parents: 16678
diff changeset
748 call StopVimInTerminal(buf)
7847d281cbbf patch 8.1.1343: text properties not adjusted for Visual block mode delete
Bram Moolenaar <Bram@vim.org>
parents: 16678
diff changeset
749 call delete('XtestPropVis')
7847d281cbbf patch 8.1.1343: text properties not adjusted for Visual block mode delete
Bram Moolenaar <Bram@vim.org>
parents: 16678
diff changeset
750 endfunc
7847d281cbbf patch 8.1.1343: text properties not adjusted for Visual block mode delete
Bram Moolenaar <Bram@vim.org>
parents: 16678
diff changeset
751
7847d281cbbf patch 8.1.1343: text properties not adjusted for Visual block mode delete
Bram Moolenaar <Bram@vim.org>
parents: 16678
diff changeset
752 " screenshot test with Visual block mode operations
7847d281cbbf patch 8.1.1343: text properties not adjusted for Visual block mode delete
Bram Moolenaar <Bram@vim.org>
parents: 16678
diff changeset
753 func Test_textprop_screenshot_visual()
18317
d2228d4cf1f6 patch 8.1.2153: combining text property and syntax highlight is wrong
Bram Moolenaar <Bram@vim.org>
parents: 17980
diff changeset
754 CheckScreendump
16682
7847d281cbbf patch 8.1.1343: text properties not adjusted for Visual block mode delete
Bram Moolenaar <Bram@vim.org>
parents: 16678
diff changeset
755
7847d281cbbf patch 8.1.1343: text properties not adjusted for Visual block mode delete
Bram Moolenaar <Bram@vim.org>
parents: 16678
diff changeset
756 " Delete two columns while text props are three chars wide.
7847d281cbbf patch 8.1.1343: text properties not adjusted for Visual block mode delete
Bram Moolenaar <Bram@vim.org>
parents: 16678
diff changeset
757 call RunTestVisualBlock(2, '01')
7847d281cbbf patch 8.1.1343: text properties not adjusted for Visual block mode delete
Bram Moolenaar <Bram@vim.org>
parents: 16678
diff changeset
758
7847d281cbbf patch 8.1.1343: text properties not adjusted for Visual block mode delete
Bram Moolenaar <Bram@vim.org>
parents: 16678
diff changeset
759 " Same, but delete four columns
7847d281cbbf patch 8.1.1343: text properties not adjusted for Visual block mode delete
Bram Moolenaar <Bram@vim.org>
parents: 16678
diff changeset
760 call RunTestVisualBlock(4, '02')
7847d281cbbf patch 8.1.1343: text properties not adjusted for Visual block mode delete
Bram Moolenaar <Bram@vim.org>
parents: 16678
diff changeset
761 endfunc
16770
09c81f17f83c patch 8.1.1387: calling prop_add() in an empty buffer doesn't work
Bram Moolenaar <Bram@vim.org>
parents: 16714
diff changeset
762
17143
ee090ecd70f6 patch 8.1.1571: textprop highlight starts too early if just after a tab
Bram Moolenaar <Bram@vim.org>
parents: 17089
diff changeset
763 func Test_textprop_after_tab()
18317
d2228d4cf1f6 patch 8.1.2153: combining text property and syntax highlight is wrong
Bram Moolenaar <Bram@vim.org>
parents: 17980
diff changeset
764 CheckScreendump
17147
a001a0d88d42 patch 8.1.1573: textprop test fails if screenhots do not work
Bram Moolenaar <Bram@vim.org>
parents: 17143
diff changeset
765
17143
ee090ecd70f6 patch 8.1.1571: textprop highlight starts too early if just after a tab
Bram Moolenaar <Bram@vim.org>
parents: 17089
diff changeset
766 let lines =<< trim END
ee090ecd70f6 patch 8.1.1571: textprop highlight starts too early if just after a tab
Bram Moolenaar <Bram@vim.org>
parents: 17089
diff changeset
767 call setline(1, [
ee090ecd70f6 patch 8.1.1571: textprop highlight starts too early if just after a tab
Bram Moolenaar <Bram@vim.org>
parents: 17089
diff changeset
768 \ "\txxx",
ee090ecd70f6 patch 8.1.1571: textprop highlight starts too early if just after a tab
Bram Moolenaar <Bram@vim.org>
parents: 17089
diff changeset
769 \ "x\txxx",
ee090ecd70f6 patch 8.1.1571: textprop highlight starts too early if just after a tab
Bram Moolenaar <Bram@vim.org>
parents: 17089
diff changeset
770 \ ])
ee090ecd70f6 patch 8.1.1571: textprop highlight starts too early if just after a tab
Bram Moolenaar <Bram@vim.org>
parents: 17089
diff changeset
771 hi SearchProp ctermbg=yellow
ee090ecd70f6 patch 8.1.1571: textprop highlight starts too early if just after a tab
Bram Moolenaar <Bram@vim.org>
parents: 17089
diff changeset
772 call prop_type_add('search', {'highlight': 'SearchProp'})
ee090ecd70f6 patch 8.1.1571: textprop highlight starts too early if just after a tab
Bram Moolenaar <Bram@vim.org>
parents: 17089
diff changeset
773 call prop_add(1, 2, {'length': 3, 'type': 'search'})
ee090ecd70f6 patch 8.1.1571: textprop highlight starts too early if just after a tab
Bram Moolenaar <Bram@vim.org>
parents: 17089
diff changeset
774 call prop_add(2, 3, {'length': 3, 'type': 'search'})
ee090ecd70f6 patch 8.1.1571: textprop highlight starts too early if just after a tab
Bram Moolenaar <Bram@vim.org>
parents: 17089
diff changeset
775 END
ee090ecd70f6 patch 8.1.1571: textprop highlight starts too early if just after a tab
Bram Moolenaar <Bram@vim.org>
parents: 17089
diff changeset
776 call writefile(lines, 'XtestPropTab')
ee090ecd70f6 patch 8.1.1571: textprop highlight starts too early if just after a tab
Bram Moolenaar <Bram@vim.org>
parents: 17089
diff changeset
777 let buf = RunVimInTerminal('-S XtestPropTab', {'rows': 6})
ee090ecd70f6 patch 8.1.1571: textprop highlight starts too early if just after a tab
Bram Moolenaar <Bram@vim.org>
parents: 17089
diff changeset
778 call VerifyScreenDump(buf, 'Test_textprop_tab', {})
ee090ecd70f6 patch 8.1.1571: textprop highlight starts too early if just after a tab
Bram Moolenaar <Bram@vim.org>
parents: 17089
diff changeset
779
ee090ecd70f6 patch 8.1.1571: textprop highlight starts too early if just after a tab
Bram Moolenaar <Bram@vim.org>
parents: 17089
diff changeset
780 " clean up
ee090ecd70f6 patch 8.1.1571: textprop highlight starts too early if just after a tab
Bram Moolenaar <Bram@vim.org>
parents: 17089
diff changeset
781 call StopVimInTerminal(buf)
ee090ecd70f6 patch 8.1.1571: textprop highlight starts too early if just after a tab
Bram Moolenaar <Bram@vim.org>
parents: 17089
diff changeset
782 call delete('XtestPropTab')
ee090ecd70f6 patch 8.1.1571: textprop highlight starts too early if just after a tab
Bram Moolenaar <Bram@vim.org>
parents: 17089
diff changeset
783 endfunc
ee090ecd70f6 patch 8.1.1571: textprop highlight starts too early if just after a tab
Bram Moolenaar <Bram@vim.org>
parents: 17089
diff changeset
784
18317
d2228d4cf1f6 patch 8.1.2153: combining text property and syntax highlight is wrong
Bram Moolenaar <Bram@vim.org>
parents: 17980
diff changeset
785 func Test_textprop_with_syntax()
d2228d4cf1f6 patch 8.1.2153: combining text property and syntax highlight is wrong
Bram Moolenaar <Bram@vim.org>
parents: 17980
diff changeset
786 CheckScreendump
d2228d4cf1f6 patch 8.1.2153: combining text property and syntax highlight is wrong
Bram Moolenaar <Bram@vim.org>
parents: 17980
diff changeset
787
d2228d4cf1f6 patch 8.1.2153: combining text property and syntax highlight is wrong
Bram Moolenaar <Bram@vim.org>
parents: 17980
diff changeset
788 let lines =<< trim END
d2228d4cf1f6 patch 8.1.2153: combining text property and syntax highlight is wrong
Bram Moolenaar <Bram@vim.org>
parents: 17980
diff changeset
789 call setline(1, [
d2228d4cf1f6 patch 8.1.2153: combining text property and syntax highlight is wrong
Bram Moolenaar <Bram@vim.org>
parents: 17980
diff changeset
790 \ "(abc)",
d2228d4cf1f6 patch 8.1.2153: combining text property and syntax highlight is wrong
Bram Moolenaar <Bram@vim.org>
parents: 17980
diff changeset
791 \ ])
d2228d4cf1f6 patch 8.1.2153: combining text property and syntax highlight is wrong
Bram Moolenaar <Bram@vim.org>
parents: 17980
diff changeset
792 syn match csParens "[()]" display
d2228d4cf1f6 patch 8.1.2153: combining text property and syntax highlight is wrong
Bram Moolenaar <Bram@vim.org>
parents: 17980
diff changeset
793 hi! link csParens MatchParen
d2228d4cf1f6 patch 8.1.2153: combining text property and syntax highlight is wrong
Bram Moolenaar <Bram@vim.org>
parents: 17980
diff changeset
794
d2228d4cf1f6 patch 8.1.2153: combining text property and syntax highlight is wrong
Bram Moolenaar <Bram@vim.org>
parents: 17980
diff changeset
795 call prop_type_add('TPTitle', #{ highlight: 'Title' })
d2228d4cf1f6 patch 8.1.2153: combining text property and syntax highlight is wrong
Bram Moolenaar <Bram@vim.org>
parents: 17980
diff changeset
796 call prop_add(1, 2, #{type: 'TPTitle', end_col: 5})
d2228d4cf1f6 patch 8.1.2153: combining text property and syntax highlight is wrong
Bram Moolenaar <Bram@vim.org>
parents: 17980
diff changeset
797 END
d2228d4cf1f6 patch 8.1.2153: combining text property and syntax highlight is wrong
Bram Moolenaar <Bram@vim.org>
parents: 17980
diff changeset
798 call writefile(lines, 'XtestPropSyn')
d2228d4cf1f6 patch 8.1.2153: combining text property and syntax highlight is wrong
Bram Moolenaar <Bram@vim.org>
parents: 17980
diff changeset
799 let buf = RunVimInTerminal('-S XtestPropSyn', {'rows': 6})
d2228d4cf1f6 patch 8.1.2153: combining text property and syntax highlight is wrong
Bram Moolenaar <Bram@vim.org>
parents: 17980
diff changeset
800 call VerifyScreenDump(buf, 'Test_textprop_syn_1', {})
d2228d4cf1f6 patch 8.1.2153: combining text property and syntax highlight is wrong
Bram Moolenaar <Bram@vim.org>
parents: 17980
diff changeset
801
d2228d4cf1f6 patch 8.1.2153: combining text property and syntax highlight is wrong
Bram Moolenaar <Bram@vim.org>
parents: 17980
diff changeset
802 " clean up
d2228d4cf1f6 patch 8.1.2153: combining text property and syntax highlight is wrong
Bram Moolenaar <Bram@vim.org>
parents: 17980
diff changeset
803 call StopVimInTerminal(buf)
d2228d4cf1f6 patch 8.1.2153: combining text property and syntax highlight is wrong
Bram Moolenaar <Bram@vim.org>
parents: 17980
diff changeset
804 call delete('XtestPropSyn')
d2228d4cf1f6 patch 8.1.2153: combining text property and syntax highlight is wrong
Bram Moolenaar <Bram@vim.org>
parents: 17980
diff changeset
805 endfunc
d2228d4cf1f6 patch 8.1.2153: combining text property and syntax highlight is wrong
Bram Moolenaar <Bram@vim.org>
parents: 17980
diff changeset
806
16770
09c81f17f83c patch 8.1.1387: calling prop_add() in an empty buffer doesn't work
Bram Moolenaar <Bram@vim.org>
parents: 16714
diff changeset
807 " Adding a text property to a new buffer should not fail
09c81f17f83c patch 8.1.1387: calling prop_add() in an empty buffer doesn't work
Bram Moolenaar <Bram@vim.org>
parents: 16714
diff changeset
808 func Test_textprop_empty_buffer()
09c81f17f83c patch 8.1.1387: calling prop_add() in an empty buffer doesn't work
Bram Moolenaar <Bram@vim.org>
parents: 16714
diff changeset
809 call prop_type_add('comment', {'highlight': 'Search'})
09c81f17f83c patch 8.1.1387: calling prop_add() in an empty buffer doesn't work
Bram Moolenaar <Bram@vim.org>
parents: 16714
diff changeset
810 new
09c81f17f83c patch 8.1.1387: calling prop_add() in an empty buffer doesn't work
Bram Moolenaar <Bram@vim.org>
parents: 16714
diff changeset
811 call prop_add(1, 1, {'type': 'comment'})
09c81f17f83c patch 8.1.1387: calling prop_add() in an empty buffer doesn't work
Bram Moolenaar <Bram@vim.org>
parents: 16714
diff changeset
812 close
16786
98ca522e6453 patch 8.1.1395: saving for undo may access invalid memory
Bram Moolenaar <Bram@vim.org>
parents: 16772
diff changeset
813 call prop_type_delete('comment')
98ca522e6453 patch 8.1.1395: saving for undo may access invalid memory
Bram Moolenaar <Bram@vim.org>
parents: 16772
diff changeset
814 endfunc
98ca522e6453 patch 8.1.1395: saving for undo may access invalid memory
Bram Moolenaar <Bram@vim.org>
parents: 16772
diff changeset
815
17208
13d0753511fe patch 8.1.1603: crash when using unknown highlighting in text property
Bram Moolenaar <Bram@vim.org>
parents: 17147
diff changeset
816 " Adding a text property with invalid highlight should be ignored.
13d0753511fe patch 8.1.1603: crash when using unknown highlighting in text property
Bram Moolenaar <Bram@vim.org>
parents: 17147
diff changeset
817 func Test_textprop_invalid_highlight()
13d0753511fe patch 8.1.1603: crash when using unknown highlighting in text property
Bram Moolenaar <Bram@vim.org>
parents: 17147
diff changeset
818 call assert_fails("call prop_type_add('dni', {'highlight': 'DoesNotExist'})", 'E970:')
13d0753511fe patch 8.1.1603: crash when using unknown highlighting in text property
Bram Moolenaar <Bram@vim.org>
parents: 17147
diff changeset
819 new
13d0753511fe patch 8.1.1603: crash when using unknown highlighting in text property
Bram Moolenaar <Bram@vim.org>
parents: 17147
diff changeset
820 call setline(1, ['asdf','asdf'])
13d0753511fe patch 8.1.1603: crash when using unknown highlighting in text property
Bram Moolenaar <Bram@vim.org>
parents: 17147
diff changeset
821 call prop_add(1, 1, {'length': 4, 'type': 'dni'})
13d0753511fe patch 8.1.1603: crash when using unknown highlighting in text property
Bram Moolenaar <Bram@vim.org>
parents: 17147
diff changeset
822 redraw
13d0753511fe patch 8.1.1603: crash when using unknown highlighting in text property
Bram Moolenaar <Bram@vim.org>
parents: 17147
diff changeset
823 bwipe!
13d0753511fe patch 8.1.1603: crash when using unknown highlighting in text property
Bram Moolenaar <Bram@vim.org>
parents: 17147
diff changeset
824 call prop_type_delete('dni')
13d0753511fe patch 8.1.1603: crash when using unknown highlighting in text property
Bram Moolenaar <Bram@vim.org>
parents: 17147
diff changeset
825 endfunc
13d0753511fe patch 8.1.1603: crash when using unknown highlighting in text property
Bram Moolenaar <Bram@vim.org>
parents: 17147
diff changeset
826
16786
98ca522e6453 patch 8.1.1395: saving for undo may access invalid memory
Bram Moolenaar <Bram@vim.org>
parents: 16772
diff changeset
827 " Adding a text property to an empty buffer and then editing another
98ca522e6453 patch 8.1.1395: saving for undo may access invalid memory
Bram Moolenaar <Bram@vim.org>
parents: 16772
diff changeset
828 func Test_textprop_empty_buffer_next()
98ca522e6453 patch 8.1.1395: saving for undo may access invalid memory
Bram Moolenaar <Bram@vim.org>
parents: 16772
diff changeset
829 call prop_type_add("xxx", {})
98ca522e6453 patch 8.1.1395: saving for undo may access invalid memory
Bram Moolenaar <Bram@vim.org>
parents: 16772
diff changeset
830 call prop_add(1, 1, {"type": "xxx"})
98ca522e6453 patch 8.1.1395: saving for undo may access invalid memory
Bram Moolenaar <Bram@vim.org>
parents: 16772
diff changeset
831 next X
98ca522e6453 patch 8.1.1395: saving for undo may access invalid memory
Bram Moolenaar <Bram@vim.org>
parents: 16772
diff changeset
832 call prop_type_delete('xxx')
16770
09c81f17f83c patch 8.1.1387: calling prop_add() in an empty buffer doesn't work
Bram Moolenaar <Bram@vim.org>
parents: 16714
diff changeset
833 endfunc
16772
18093a6accb5 patch 8.1.1388: errors when calling prop_remove() for an unloaded buffer
Bram Moolenaar <Bram@vim.org>
parents: 16770
diff changeset
834
18093a6accb5 patch 8.1.1388: errors when calling prop_remove() for an unloaded buffer
Bram Moolenaar <Bram@vim.org>
parents: 16770
diff changeset
835 func Test_textprop_remove_from_buf()
18093a6accb5 patch 8.1.1388: errors when calling prop_remove() for an unloaded buffer
Bram Moolenaar <Bram@vim.org>
parents: 16770
diff changeset
836 new
18093a6accb5 patch 8.1.1388: errors when calling prop_remove() for an unloaded buffer
Bram Moolenaar <Bram@vim.org>
parents: 16770
diff changeset
837 let buf = bufnr('')
18093a6accb5 patch 8.1.1388: errors when calling prop_remove() for an unloaded buffer
Bram Moolenaar <Bram@vim.org>
parents: 16770
diff changeset
838 call prop_type_add('one', {'bufnr': buf})
18093a6accb5 patch 8.1.1388: errors when calling prop_remove() for an unloaded buffer
Bram Moolenaar <Bram@vim.org>
parents: 16770
diff changeset
839 call prop_add(1, 1, {'type': 'one', 'id': 234})
18093a6accb5 patch 8.1.1388: errors when calling prop_remove() for an unloaded buffer
Bram Moolenaar <Bram@vim.org>
parents: 16770
diff changeset
840 file x
18093a6accb5 patch 8.1.1388: errors when calling prop_remove() for an unloaded buffer
Bram Moolenaar <Bram@vim.org>
parents: 16770
diff changeset
841 edit y
18093a6accb5 patch 8.1.1388: errors when calling prop_remove() for an unloaded buffer
Bram Moolenaar <Bram@vim.org>
parents: 16770
diff changeset
842 call prop_remove({'id': 234, 'bufnr': buf}, 1)
18093a6accb5 patch 8.1.1388: errors when calling prop_remove() for an unloaded buffer
Bram Moolenaar <Bram@vim.org>
parents: 16770
diff changeset
843 call prop_type_delete('one', {'bufnr': buf})
18093a6accb5 patch 8.1.1388: errors when calling prop_remove() for an unloaded buffer
Bram Moolenaar <Bram@vim.org>
parents: 16770
diff changeset
844 bwipe! x
18093a6accb5 patch 8.1.1388: errors when calling prop_remove() for an unloaded buffer
Bram Moolenaar <Bram@vim.org>
parents: 16770
diff changeset
845 close
18093a6accb5 patch 8.1.1388: errors when calling prop_remove() for an unloaded buffer
Bram Moolenaar <Bram@vim.org>
parents: 16770
diff changeset
846 endfunc
17694
6f9cde96ee3c patch 8.1.1844: buffer no longer unloaded when adding text properties
Bram Moolenaar <Bram@vim.org>
parents: 17208
diff changeset
847
6f9cde96ee3c patch 8.1.1844: buffer no longer unloaded when adding text properties
Bram Moolenaar <Bram@vim.org>
parents: 17208
diff changeset
848 func Test_textprop_in_unloaded_buf()
6f9cde96ee3c patch 8.1.1844: buffer no longer unloaded when adding text properties
Bram Moolenaar <Bram@vim.org>
parents: 17208
diff changeset
849 edit Xaaa
6f9cde96ee3c patch 8.1.1844: buffer no longer unloaded when adding text properties
Bram Moolenaar <Bram@vim.org>
parents: 17208
diff changeset
850 call setline(1, 'aaa')
6f9cde96ee3c patch 8.1.1844: buffer no longer unloaded when adding text properties
Bram Moolenaar <Bram@vim.org>
parents: 17208
diff changeset
851 write
6f9cde96ee3c patch 8.1.1844: buffer no longer unloaded when adding text properties
Bram Moolenaar <Bram@vim.org>
parents: 17208
diff changeset
852 edit Xbbb
6f9cde96ee3c patch 8.1.1844: buffer no longer unloaded when adding text properties
Bram Moolenaar <Bram@vim.org>
parents: 17208
diff changeset
853 call setline(1, 'bbb')
6f9cde96ee3c patch 8.1.1844: buffer no longer unloaded when adding text properties
Bram Moolenaar <Bram@vim.org>
parents: 17208
diff changeset
854 write
6f9cde96ee3c patch 8.1.1844: buffer no longer unloaded when adding text properties
Bram Moolenaar <Bram@vim.org>
parents: 17208
diff changeset
855 let bnr = bufnr('')
6f9cde96ee3c patch 8.1.1844: buffer no longer unloaded when adding text properties
Bram Moolenaar <Bram@vim.org>
parents: 17208
diff changeset
856 edit Xaaa
6f9cde96ee3c patch 8.1.1844: buffer no longer unloaded when adding text properties
Bram Moolenaar <Bram@vim.org>
parents: 17208
diff changeset
857
6f9cde96ee3c patch 8.1.1844: buffer no longer unloaded when adding text properties
Bram Moolenaar <Bram@vim.org>
parents: 17208
diff changeset
858 call prop_type_add('ErrorMsg', #{highlight:'ErrorMsg'})
6f9cde96ee3c patch 8.1.1844: buffer no longer unloaded when adding text properties
Bram Moolenaar <Bram@vim.org>
parents: 17208
diff changeset
859 call assert_fails("call prop_add(1, 1, #{end_lnum: 1, endcol: 2, type: 'ErrorMsg', bufnr: bnr})", 'E275:')
6f9cde96ee3c patch 8.1.1844: buffer no longer unloaded when adding text properties
Bram Moolenaar <Bram@vim.org>
parents: 17208
diff changeset
860 exe 'buf ' .. bnr
6f9cde96ee3c patch 8.1.1844: buffer no longer unloaded when adding text properties
Bram Moolenaar <Bram@vim.org>
parents: 17208
diff changeset
861 call assert_equal('bbb', getline(1))
6f9cde96ee3c patch 8.1.1844: buffer no longer unloaded when adding text properties
Bram Moolenaar <Bram@vim.org>
parents: 17208
diff changeset
862 call assert_equal(0, prop_list(1)->len())
6f9cde96ee3c patch 8.1.1844: buffer no longer unloaded when adding text properties
Bram Moolenaar <Bram@vim.org>
parents: 17208
diff changeset
863
6f9cde96ee3c patch 8.1.1844: buffer no longer unloaded when adding text properties
Bram Moolenaar <Bram@vim.org>
parents: 17208
diff changeset
864 bwipe! Xaaa
6f9cde96ee3c patch 8.1.1844: buffer no longer unloaded when adding text properties
Bram Moolenaar <Bram@vim.org>
parents: 17208
diff changeset
865 bwipe! Xbbb
6f9cde96ee3c patch 8.1.1844: buffer no longer unloaded when adding text properties
Bram Moolenaar <Bram@vim.org>
parents: 17208
diff changeset
866 cal delete('Xaaa')
6f9cde96ee3c patch 8.1.1844: buffer no longer unloaded when adding text properties
Bram Moolenaar <Bram@vim.org>
parents: 17208
diff changeset
867 cal delete('Xbbb')
6f9cde96ee3c patch 8.1.1844: buffer no longer unloaded when adding text properties
Bram Moolenaar <Bram@vim.org>
parents: 17208
diff changeset
868 endfunc
18444
967ca19425e3 patch 8.1.2216: text property in wrong place after :substitute
Bram Moolenaar <Bram@vim.org>
parents: 18317
diff changeset
869
967ca19425e3 patch 8.1.2216: text property in wrong place after :substitute
Bram Moolenaar <Bram@vim.org>
parents: 18317
diff changeset
870 func Test_proptype_substitute2()
967ca19425e3 patch 8.1.2216: text property in wrong place after :substitute
Bram Moolenaar <Bram@vim.org>
parents: 18317
diff changeset
871 new
967ca19425e3 patch 8.1.2216: text property in wrong place after :substitute
Bram Moolenaar <Bram@vim.org>
parents: 18317
diff changeset
872 " text_prop.vim
967ca19425e3 patch 8.1.2216: text property in wrong place after :substitute
Bram Moolenaar <Bram@vim.org>
parents: 18317
diff changeset
873 call setline(1, [
967ca19425e3 patch 8.1.2216: text property in wrong place after :substitute
Bram Moolenaar <Bram@vim.org>
parents: 18317
diff changeset
874 \ 'The num 123 is smaller than 4567.',
967ca19425e3 patch 8.1.2216: text property in wrong place after :substitute
Bram Moolenaar <Bram@vim.org>
parents: 18317
diff changeset
875 \ '123 The number 123 is smaller than 4567.',
967ca19425e3 patch 8.1.2216: text property in wrong place after :substitute
Bram Moolenaar <Bram@vim.org>
parents: 18317
diff changeset
876 \ '123 The number 123 is smaller than 4567.'])
967ca19425e3 patch 8.1.2216: text property in wrong place after :substitute
Bram Moolenaar <Bram@vim.org>
parents: 18317
diff changeset
877
967ca19425e3 patch 8.1.2216: text property in wrong place after :substitute
Bram Moolenaar <Bram@vim.org>
parents: 18317
diff changeset
878 call prop_type_add('number', {'highlight': 'ErrorMsg'})
967ca19425e3 patch 8.1.2216: text property in wrong place after :substitute
Bram Moolenaar <Bram@vim.org>
parents: 18317
diff changeset
879
967ca19425e3 patch 8.1.2216: text property in wrong place after :substitute
Bram Moolenaar <Bram@vim.org>
parents: 18317
diff changeset
880 call prop_add(1, 12, {'length': 3, 'type': 'number'})
967ca19425e3 patch 8.1.2216: text property in wrong place after :substitute
Bram Moolenaar <Bram@vim.org>
parents: 18317
diff changeset
881 call prop_add(2, 1, {'length': 3, 'type': 'number'})
967ca19425e3 patch 8.1.2216: text property in wrong place after :substitute
Bram Moolenaar <Bram@vim.org>
parents: 18317
diff changeset
882 call prop_add(3, 36, {'length': 4, 'type': 'number'})
967ca19425e3 patch 8.1.2216: text property in wrong place after :substitute
Bram Moolenaar <Bram@vim.org>
parents: 18317
diff changeset
883 set ul&
967ca19425e3 patch 8.1.2216: text property in wrong place after :substitute
Bram Moolenaar <Bram@vim.org>
parents: 18317
diff changeset
884 let expected = [{'id': 0, 'col': 13, 'end': 1, 'type': 'number', 'length': 3, 'start': 1},
967ca19425e3 patch 8.1.2216: text property in wrong place after :substitute
Bram Moolenaar <Bram@vim.org>
parents: 18317
diff changeset
885 \ {'id': 0, 'col': 1, 'end': 1, 'type': 'number', 'length': 3, 'start': 1},
967ca19425e3 patch 8.1.2216: text property in wrong place after :substitute
Bram Moolenaar <Bram@vim.org>
parents: 18317
diff changeset
886 \ {'id': 0, 'col': 50, 'end': 1, 'type': 'number', 'length': 4, 'start': 1}]
967ca19425e3 patch 8.1.2216: text property in wrong place after :substitute
Bram Moolenaar <Bram@vim.org>
parents: 18317
diff changeset
887 " Add some text in between
967ca19425e3 patch 8.1.2216: text property in wrong place after :substitute
Bram Moolenaar <Bram@vim.org>
parents: 18317
diff changeset
888 %s/\s\+/ /g
967ca19425e3 patch 8.1.2216: text property in wrong place after :substitute
Bram Moolenaar <Bram@vim.org>
parents: 18317
diff changeset
889 call assert_equal(expected, prop_list(1) + prop_list(2) + prop_list(3))
967ca19425e3 patch 8.1.2216: text property in wrong place after :substitute
Bram Moolenaar <Bram@vim.org>
parents: 18317
diff changeset
890
967ca19425e3 patch 8.1.2216: text property in wrong place after :substitute
Bram Moolenaar <Bram@vim.org>
parents: 18317
diff changeset
891 " remove some text
967ca19425e3 patch 8.1.2216: text property in wrong place after :substitute
Bram Moolenaar <Bram@vim.org>
parents: 18317
diff changeset
892 :1s/[a-z]\{3\}//g
967ca19425e3 patch 8.1.2216: text property in wrong place after :substitute
Bram Moolenaar <Bram@vim.org>
parents: 18317
diff changeset
893 let expected = [{'id': 0, 'col': 10, 'end': 1, 'type': 'number', 'length': 3, 'start': 1}]
967ca19425e3 patch 8.1.2216: text property in wrong place after :substitute
Bram Moolenaar <Bram@vim.org>
parents: 18317
diff changeset
894 call assert_equal(expected, prop_list(1))
967ca19425e3 patch 8.1.2216: text property in wrong place after :substitute
Bram Moolenaar <Bram@vim.org>
parents: 18317
diff changeset
895 bwipe!
967ca19425e3 patch 8.1.2216: text property in wrong place after :substitute
Bram Moolenaar <Bram@vim.org>
parents: 18317
diff changeset
896 endfunc