annotate src/testdir/test_textprop.vim @ 19631:1d493fce1fbd v8.2.0372

patch 8.2.0372: prop_find() may not find text property at start of the line Commit: https://github.com/vim/vim/commit/66b98854d86f641db036fd1e6cf20f7b8905344e Author: Bram Moolenaar <Bram@vim.org> Date: Wed Mar 11 19:15:52 2020 +0100 patch 8.2.0372: prop_find() may not find text property at start of the line Problem: Prop_find() may not find text property at start of the line. Solution: Adjust the loop to find properties. (Axel Forsman, closes https://github.com/vim/vim/issues/5761, closes #5663)
author Bram Moolenaar <Bram@vim.org>
date Wed, 11 Mar 2020 21:31:02 +0100
parents 67f39cb0a49c
children 647ef636a11e
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
15138
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
9 func Test_proptype_global()
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
10 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
11 let proptypes = prop_type_list()
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
12 call assert_equal(1, len(proptypes))
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
13 call assert_equal('comment', proptypes[0])
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
14
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
15 let proptype = prop_type_get('comment')
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
16 call assert_equal('Directory', proptype['highlight'])
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
17 call assert_equal(123, proptype['priority'])
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
18 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
19 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
20
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
21 call prop_type_delete('comment')
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
22 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
23
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
24 call prop_type_add('one', {})
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
25 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
26 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
27 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
28 call assert_equal(0, proptype['priority'])
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
29 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
30 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
31
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
32 call prop_type_add('two', {})
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
33 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
34 call prop_type_delete('one')
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
35 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
36 call prop_type_delete('two')
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
37 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
38 endfunc
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
39
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
40 func Test_proptype_buf()
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
41 let bufnr = bufnr('')
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
42 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
43 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
44 call assert_equal(1, len(proptypes))
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
45 call assert_equal('comment', proptypes[0])
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
46
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
47 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
48 call assert_equal('Directory', proptype['highlight'])
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
49 call assert_equal(123, proptype['priority'])
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
50 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
51 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
52
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
53 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
54 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
55
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
56 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
57 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
58 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
59 call assert_equal(0, proptype['priority'])
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
60 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
61 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
62
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
63 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
64 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
65 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
66 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
67 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
68 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
69
18093a6accb5 patch 8.1.1388: errors when calling prop_remove() for an unloaded buffer
Bram Moolenaar <Bram@vim.org>
parents: 16770
diff changeset
70 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
71 endfunc
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
72
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
73 func AddPropTypes()
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
74 call prop_type_add('one', {})
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
75 call prop_type_add('two', {})
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
76 call prop_type_add('three', {})
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
77 call prop_type_add('whole', {})
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
78 endfunc
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
79
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
80 func DeletePropTypes()
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
81 call prop_type_delete('one')
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
82 call prop_type_delete('two')
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
83 call prop_type_delete('three')
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
84 call prop_type_delete('whole')
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
85 endfunc
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
86
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
87 func SetupPropsInFirstLine()
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
88 call setline(1, 'one two three')
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
89 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
90 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
91 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
92 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
93 endfunc
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
94
15367
273649cad196 patch 8.1.0691: text properties are not adjusted for :substitute
Bram Moolenaar <Bram@vim.org>
parents: 15365
diff changeset
95 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
96 return [
273649cad196 patch 8.1.0691: text properties are not adjusted for :substitute
Bram Moolenaar <Bram@vim.org>
parents: 15365
diff changeset
97 \ {'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
98 \ {'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
99 \ {'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
100 \ {'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
101 \ ]
15367
273649cad196 patch 8.1.0691: text properties are not adjusted for :substitute
Bram Moolenaar <Bram@vim.org>
parents: 15365
diff changeset
102 endfunc
15138
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
103
19100
91bb12995034 patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents: 19097
diff changeset
104 func Test_prop_find()
91bb12995034 patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents: 19097
diff changeset
105 new
91bb12995034 patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents: 19097
diff changeset
106 call setline(1, ['one one one', 'twotwo', 'three', 'fourfour', 'five', 'sixsix'])
91bb12995034 patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents: 19097
diff changeset
107
91bb12995034 patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents: 19097
diff changeset
108 " Add two text props on lines 1 and 5, and one spanning lines 2 to 4.
91bb12995034 patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents: 19097
diff changeset
109 call prop_type_add('prop_name', {'highlight': 'Directory'})
91bb12995034 patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents: 19097
diff changeset
110 call prop_add(1, 5, {'type': 'prop_name', 'id': 10, 'length': 3})
91bb12995034 patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents: 19097
diff changeset
111 call prop_add(2, 4, {'type': 'prop_name', 'id': 11, 'end_lnum': 4, 'end_col': 9})
91bb12995034 patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents: 19097
diff changeset
112 call prop_add(5, 4, {'type': 'prop_name', 'id': 12, 'length': 1})
91bb12995034 patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents: 19097
diff changeset
113
91bb12995034 patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents: 19097
diff changeset
114 let expected = [
91bb12995034 patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents: 19097
diff changeset
115 \ {'lnum': 1, 'col': 5, 'length': 3, 'id': 10, 'type': 'prop_name', 'start': 1, 'end': 1},
91bb12995034 patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents: 19097
diff changeset
116 \ {'lnum': 2, 'col': 4, 'id': 11, 'type': 'prop_name', 'start': 1, 'end': 0},
91bb12995034 patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents: 19097
diff changeset
117 \ {'lnum': 5, 'col': 4, 'length': 1, 'id': 12, 'type': 'prop_name', 'start': 1, 'end': 1}
91bb12995034 patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents: 19097
diff changeset
118 \ ]
91bb12995034 patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents: 19097
diff changeset
119
91bb12995034 patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents: 19097
diff changeset
120 " Starting at line 5 col 1 this should find the prop at line 5 col 4.
91bb12995034 patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents: 19097
diff changeset
121 call cursor(5,1)
91bb12995034 patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents: 19097
diff changeset
122 let result = prop_find({'type': 'prop_name'}, 'f')
91bb12995034 patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents: 19097
diff changeset
123 call assert_equal(expected[2], result)
91bb12995034 patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents: 19097
diff changeset
124
91bb12995034 patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents: 19097
diff changeset
125 " With skipstart left at false (default), this should find the prop at line
91bb12995034 patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents: 19097
diff changeset
126 " 5 col 4.
91bb12995034 patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents: 19097
diff changeset
127 let result = prop_find({'type': 'prop_name', 'lnum': 5, 'col': 4}, 'b')
91bb12995034 patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents: 19097
diff changeset
128 call assert_equal(expected[2], result)
91bb12995034 patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents: 19097
diff changeset
129
91bb12995034 patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents: 19097
diff changeset
130 " With skipstart set to true, this should skip the prop at line 5 col 4.
91bb12995034 patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents: 19097
diff changeset
131 let result = prop_find({'type': 'prop_name', 'lnum': 5, 'col': 4, 'skipstart': 1}, 'b')
91bb12995034 patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents: 19097
diff changeset
132 unlet result.length
91bb12995034 patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents: 19097
diff changeset
133 call assert_equal(expected[1], result)
91bb12995034 patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents: 19097
diff changeset
134
91bb12995034 patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents: 19097
diff changeset
135 " Search backwards from line 1 col 10 to find the prop on the same line.
91bb12995034 patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents: 19097
diff changeset
136 let result = prop_find({'type': 'prop_name', 'lnum': 1, 'col': 10}, 'b')
91bb12995034 patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents: 19097
diff changeset
137 call assert_equal(expected[0], result)
91bb12995034 patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents: 19097
diff changeset
138
91bb12995034 patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents: 19097
diff changeset
139 " with skipstart set to false, if the start position is anywhere between the
91bb12995034 patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents: 19097
diff changeset
140 " start and end lines of a text prop (searching forward or backward), the
91bb12995034 patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents: 19097
diff changeset
141 " result should be the prop on the first line (the line with 'start' set to 1).
91bb12995034 patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents: 19097
diff changeset
142 call cursor(3,1)
91bb12995034 patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents: 19097
diff changeset
143 let result = prop_find({'type': 'prop_name'}, 'f')
91bb12995034 patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents: 19097
diff changeset
144 unlet result.length
91bb12995034 patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents: 19097
diff changeset
145 call assert_equal(expected[1], result)
91bb12995034 patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents: 19097
diff changeset
146 let result = prop_find({'type': 'prop_name'}, 'b')
91bb12995034 patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents: 19097
diff changeset
147 unlet result.length
91bb12995034 patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents: 19097
diff changeset
148 call assert_equal(expected[1], result)
91bb12995034 patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents: 19097
diff changeset
149
91bb12995034 patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents: 19097
diff changeset
150 " with skipstart set to true, if the start position is anywhere between the
91bb12995034 patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents: 19097
diff changeset
151 " start and end lines of a text prop (searching forward or backward), all lines
91bb12995034 patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents: 19097
diff changeset
152 " of the prop will be skipped.
91bb12995034 patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents: 19097
diff changeset
153 let result = prop_find({'type': 'prop_name', 'skipstart': 1}, 'b')
91bb12995034 patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents: 19097
diff changeset
154 call assert_equal(expected[0], result)
91bb12995034 patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents: 19097
diff changeset
155 let result = prop_find({'type': 'prop_name', 'skipstart': 1}, 'f')
91bb12995034 patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents: 19097
diff changeset
156 call assert_equal(expected[2], result)
91bb12995034 patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents: 19097
diff changeset
157
91bb12995034 patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents: 19097
diff changeset
158 " Use skipstart to search through all props with type name 'prop_name'.
91bb12995034 patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents: 19097
diff changeset
159 " First forward...
91bb12995034 patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents: 19097
diff changeset
160 let lnum = 1
91bb12995034 patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents: 19097
diff changeset
161 let col = 1
91bb12995034 patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents: 19097
diff changeset
162 let i = 0
91bb12995034 patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents: 19097
diff changeset
163 for exp in expected
91bb12995034 patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents: 19097
diff changeset
164 let result = prop_find({'type': 'prop_name', 'lnum': lnum, 'col': col, 'skipstart': 1}, 'f')
91bb12995034 patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents: 19097
diff changeset
165 if !has_key(exp, "length")
91bb12995034 patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents: 19097
diff changeset
166 unlet result.length
91bb12995034 patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents: 19097
diff changeset
167 endif
91bb12995034 patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents: 19097
diff changeset
168 call assert_equal(exp, result)
91bb12995034 patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents: 19097
diff changeset
169 let lnum = result.lnum
91bb12995034 patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents: 19097
diff changeset
170 let col = result.col
91bb12995034 patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents: 19097
diff changeset
171 let i = i + 1
91bb12995034 patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents: 19097
diff changeset
172 endfor
91bb12995034 patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents: 19097
diff changeset
173
91bb12995034 patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents: 19097
diff changeset
174 " ...then backwards.
91bb12995034 patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents: 19097
diff changeset
175 let lnum = 6
91bb12995034 patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents: 19097
diff changeset
176 let col = 4
91bb12995034 patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents: 19097
diff changeset
177 let i = 2
91bb12995034 patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents: 19097
diff changeset
178 while i >= 0
91bb12995034 patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents: 19097
diff changeset
179 let result = prop_find({'type': 'prop_name', 'lnum': lnum, 'col': col, 'skipstart': 1}, 'b')
91bb12995034 patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents: 19097
diff changeset
180 if !has_key(expected[i], "length")
91bb12995034 patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents: 19097
diff changeset
181 unlet result.length
91bb12995034 patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents: 19097
diff changeset
182 endif
91bb12995034 patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents: 19097
diff changeset
183 call assert_equal(expected[i], result)
91bb12995034 patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents: 19097
diff changeset
184 let lnum = result.lnum
91bb12995034 patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents: 19097
diff changeset
185 let col = result.col
91bb12995034 patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents: 19097
diff changeset
186 let i = i - 1
91bb12995034 patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents: 19097
diff changeset
187 endwhile
91bb12995034 patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents: 19097
diff changeset
188
91bb12995034 patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents: 19097
diff changeset
189 " Starting from line 6 col 1 search backwards for prop with id 10.
91bb12995034 patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents: 19097
diff changeset
190 call cursor(6,1)
91bb12995034 patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents: 19097
diff changeset
191 let result = prop_find({'id': 10, 'skipstart': 1}, 'b')
91bb12995034 patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents: 19097
diff changeset
192 call assert_equal(expected[0], result)
91bb12995034 patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents: 19097
diff changeset
193
91bb12995034 patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents: 19097
diff changeset
194 " Starting from line 1 col 1 search forwards for prop with id 12.
91bb12995034 patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents: 19097
diff changeset
195 call cursor(1,1)
91bb12995034 patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents: 19097
diff changeset
196 let result = prop_find({'id': 12}, 'f')
91bb12995034 patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents: 19097
diff changeset
197 call assert_equal(expected[2], result)
91bb12995034 patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents: 19097
diff changeset
198
91bb12995034 patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents: 19097
diff changeset
199 " Search for a prop with an unknown id.
91bb12995034 patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents: 19097
diff changeset
200 let result = prop_find({'id': 999}, 'f')
91bb12995034 patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents: 19097
diff changeset
201 call assert_equal({}, result)
91bb12995034 patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents: 19097
diff changeset
202
91bb12995034 patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents: 19097
diff changeset
203 " Search backwards from the proceeding position of the prop with id 11
91bb12995034 patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents: 19097
diff changeset
204 " (at line num 2 col 4). This should return an empty dict.
91bb12995034 patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents: 19097
diff changeset
205 let result = prop_find({'id': 11, 'lnum': 2, 'col': 3}, 'b')
91bb12995034 patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents: 19097
diff changeset
206 call assert_equal({}, result)
91bb12995034 patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents: 19097
diff changeset
207
91bb12995034 patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents: 19097
diff changeset
208 " When lnum is given and col is omitted, use column 1.
91bb12995034 patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents: 19097
diff changeset
209 let result = prop_find({'type': 'prop_name', 'lnum': 1}, 'f')
91bb12995034 patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents: 19097
diff changeset
210 call assert_equal(expected[0], result)
91bb12995034 patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents: 19097
diff changeset
211
91bb12995034 patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents: 19097
diff changeset
212 call prop_clear(1,6)
91bb12995034 patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents: 19097
diff changeset
213 call prop_type_delete('prop_name')
91bb12995034 patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents: 19097
diff changeset
214 endfunc
91bb12995034 patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents: 19097
diff changeset
215
15138
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
216 func Test_prop_add()
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
217 new
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
218 call AddPropTypes()
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
219 call SetupPropsInFirstLine()
15367
273649cad196 patch 8.1.0691: text properties are not adjusted for :substitute
Bram Moolenaar <Bram@vim.org>
parents: 15365
diff changeset
220 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
221 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
222 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
223 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
224
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
225 " 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
226 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
227 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
228 " 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
229 1del
15367
273649cad196 patch 8.1.0691: text properties are not adjusted for :substitute
Bram Moolenaar <Bram@vim.org>
parents: 15365
diff changeset
230 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
231
15335
18c20ceee4b5 patch 8.1.0675: text property column in screen columns is not practical
Bram Moolenaar <Bram@vim.org>
parents: 15318
diff changeset
232 " 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
233 call prop_clear(1)
19534
36ec10251b2b patch 8.2.0324: text property not updated correctly when inserting/deleting
Bram Moolenaar <Bram@vim.org>
parents: 19110
diff changeset
234 call prop_type_add('included', {'start_incl': 1, 'end_incl': 1})
36ec10251b2b patch 8.2.0324: text property not updated correctly when inserting/deleting
Bram Moolenaar <Bram@vim.org>
parents: 19110
diff changeset
235 call prop_add(1, 5, #{type: 'included'})
36ec10251b2b patch 8.2.0324: text property not updated correctly when inserting/deleting
Bram Moolenaar <Bram@vim.org>
parents: 19110
diff changeset
236 let expected = [#{col: 5, length: 0, type: 'included', id: 0, start: 1, end: 1}]
36ec10251b2b patch 8.2.0324: text property not updated correctly when inserting/deleting
Bram Moolenaar <Bram@vim.org>
parents: 19110
diff changeset
237 call assert_equal(expected, prop_list(1))
36ec10251b2b patch 8.2.0324: text property not updated correctly when inserting/deleting
Bram Moolenaar <Bram@vim.org>
parents: 19110
diff changeset
238
36ec10251b2b patch 8.2.0324: text property not updated correctly when inserting/deleting
Bram Moolenaar <Bram@vim.org>
parents: 19110
diff changeset
239 " Inserting text makes the prop bigger.
36ec10251b2b patch 8.2.0324: text property not updated correctly when inserting/deleting
Bram Moolenaar <Bram@vim.org>
parents: 19110
diff changeset
240 exe "normal 5|ixx\<Esc>"
36ec10251b2b patch 8.2.0324: text property not updated correctly when inserting/deleting
Bram Moolenaar <Bram@vim.org>
parents: 19110
diff changeset
241 let expected = [#{col: 5, length: 2, type: 'included', id: 0, start: 1, end: 1}]
15335
18c20ceee4b5 patch 8.1.0675: text property column in screen columns is not practical
Bram Moolenaar <Bram@vim.org>
parents: 15318
diff changeset
242 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
243
16772
18093a6accb5 patch 8.1.1388: errors when calling prop_remove() for an unloaded buffer
Bram Moolenaar <Bram@vim.org>
parents: 16770
diff changeset
244 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
245
15138
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
246 call DeletePropTypes()
19534
36ec10251b2b patch 8.2.0324: text property not updated correctly when inserting/deleting
Bram Moolenaar <Bram@vim.org>
parents: 19110
diff changeset
247 call prop_type_delete('included')
15138
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
248 bwipe!
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
249 endfunc
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
250
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
251 func Test_prop_remove()
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
252 new
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
253 call AddPropTypes()
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
254 call SetupPropsInFirstLine()
15367
273649cad196 patch 8.1.0691: text properties are not adjusted for :substitute
Bram Moolenaar <Bram@vim.org>
parents: 15365
diff changeset
255 let props = Get_expected_props()
15138
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
256 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
257
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
258 " 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
259 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
260 unlet props[2]
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
261 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
262
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
263 " 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
264 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
265 unlet props[1]
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
266 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
267
16772
18093a6accb5 patch 8.1.1388: errors when calling prop_remove() for an unloaded buffer
Bram Moolenaar <Bram@vim.org>
parents: 16770
diff changeset
268 " 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
269 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
270
15138
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
271 call DeletePropTypes()
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
272 bwipe!
19601
67f39cb0a49c patch 8.2.0357: cannot delete a text property matching both id and type
Bram Moolenaar <Bram@vim.org>
parents: 19534
diff changeset
273
67f39cb0a49c patch 8.2.0357: cannot delete a text property matching both id and type
Bram Moolenaar <Bram@vim.org>
parents: 19534
diff changeset
274 new
67f39cb0a49c patch 8.2.0357: cannot delete a text property matching both id and type
Bram Moolenaar <Bram@vim.org>
parents: 19534
diff changeset
275 call AddPropTypes()
67f39cb0a49c patch 8.2.0357: cannot delete a text property matching both id and type
Bram Moolenaar <Bram@vim.org>
parents: 19534
diff changeset
276 call SetupPropsInFirstLine()
67f39cb0a49c patch 8.2.0357: cannot delete a text property matching both id and type
Bram Moolenaar <Bram@vim.org>
parents: 19534
diff changeset
277 call prop_add(1, 6, {'length': 2, 'id': 11, 'type': 'three'})
67f39cb0a49c patch 8.2.0357: cannot delete a text property matching both id and type
Bram Moolenaar <Bram@vim.org>
parents: 19534
diff changeset
278 let props = Get_expected_props()
67f39cb0a49c patch 8.2.0357: cannot delete a text property matching both id and type
Bram Moolenaar <Bram@vim.org>
parents: 19534
diff changeset
279 call insert(props, {'col': 6, 'length': 2, 'id': 11, 'type': 'three', 'start': 1, 'end': 1}, 3)
67f39cb0a49c patch 8.2.0357: cannot delete a text property matching both id and type
Bram Moolenaar <Bram@vim.org>
parents: 19534
diff changeset
280 call assert_equal(props, prop_list(1))
67f39cb0a49c patch 8.2.0357: cannot delete a text property matching both id and type
Bram Moolenaar <Bram@vim.org>
parents: 19534
diff changeset
281 call assert_equal(1, prop_remove({'type': 'three', 'id': 11, 'both': 1, 'all': 1}, 1))
67f39cb0a49c patch 8.2.0357: cannot delete a text property matching both id and type
Bram Moolenaar <Bram@vim.org>
parents: 19534
diff changeset
282 unlet props[3]
67f39cb0a49c patch 8.2.0357: cannot delete a text property matching both id and type
Bram Moolenaar <Bram@vim.org>
parents: 19534
diff changeset
283 call assert_equal(props, prop_list(1))
67f39cb0a49c patch 8.2.0357: cannot delete a text property matching both id and type
Bram Moolenaar <Bram@vim.org>
parents: 19534
diff changeset
284
67f39cb0a49c patch 8.2.0357: cannot delete a text property matching both id and type
Bram Moolenaar <Bram@vim.org>
parents: 19534
diff changeset
285 call assert_fails("call prop_remove({'id': 11, 'both': 1})", 'E860')
67f39cb0a49c patch 8.2.0357: cannot delete a text property matching both id and type
Bram Moolenaar <Bram@vim.org>
parents: 19534
diff changeset
286 call assert_fails("call prop_remove({'type': 'three', 'both': 1})", 'E860')
67f39cb0a49c patch 8.2.0357: cannot delete a text property matching both id and type
Bram Moolenaar <Bram@vim.org>
parents: 19534
diff changeset
287
67f39cb0a49c patch 8.2.0357: cannot delete a text property matching both id and type
Bram Moolenaar <Bram@vim.org>
parents: 19534
diff changeset
288 call DeletePropTypes()
67f39cb0a49c patch 8.2.0357: cannot delete a text property matching both id and type
Bram Moolenaar <Bram@vim.org>
parents: 19534
diff changeset
289 bwipe!
15138
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
290 endfunc
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
291
15349
6abee072b93c patch 8.1.0682: text properties not adjusted when backspacing replaced text
Bram Moolenaar <Bram@vim.org>
parents: 15347
diff changeset
292 func SetupOneLine()
6abee072b93c patch 8.1.0682: text properties not adjusted when backspacing replaced text
Bram Moolenaar <Bram@vim.org>
parents: 15347
diff changeset
293 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
294 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
295 call AddPropTypes()
6abee072b93c patch 8.1.0682: text properties not adjusted when backspacing replaced text
Bram Moolenaar <Bram@vim.org>
parents: 15347
diff changeset
296 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
297 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
298 let expected = [
6abee072b93c patch 8.1.0682: text properties not adjusted when backspacing replaced text
Bram Moolenaar <Bram@vim.org>
parents: 15347
diff changeset
299 \ {'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
300 \ {'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
301 \]
6abee072b93c patch 8.1.0682: text properties not adjusted when backspacing replaced text
Bram Moolenaar <Bram@vim.org>
parents: 15347
diff changeset
302 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
303 return expected
6abee072b93c patch 8.1.0682: text properties not adjusted when backspacing replaced text
Bram Moolenaar <Bram@vim.org>
parents: 15347
diff changeset
304 endfunc
6abee072b93c patch 8.1.0682: text properties not adjusted when backspacing replaced text
Bram Moolenaar <Bram@vim.org>
parents: 15347
diff changeset
305
15138
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
306 func Test_prop_add_remove_buf()
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
307 new
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
308 let bufnr = bufnr('')
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
309 call AddPropTypes()
16060
176872829dc2 patch 8.1.1035: prop_remove() second argument is not optional
Bram Moolenaar <Bram@vim.org>
parents: 15928
diff changeset
310 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
311 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
312 endfor
15138
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
313 wincmd w
16060
176872829dc2 patch 8.1.1035: prop_remove() second argument is not optional
Bram Moolenaar <Bram@vim.org>
parents: 15928
diff changeset
314 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
315 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
316 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
317 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
318 endfor
176872829dc2 patch 8.1.1035: prop_remove() second argument is not optional
Bram Moolenaar <Bram@vim.org>
parents: 15928
diff changeset
319
15138
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
320 let props = [
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
321 \ {'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
322 \ {'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
323 \ {'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
324 \]
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
325 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
326
15138
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
327 " 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
328 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
329 unlet props[1]
176872829dc2 patch 8.1.1035: prop_remove() second argument is not optional
Bram Moolenaar <Bram@vim.org>
parents: 15928
diff changeset
330
15138
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
331 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
332 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
333 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
334 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
335 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
336
176872829dc2 patch 8.1.1035: prop_remove() second argument is not optional
Bram Moolenaar <Bram@vim.org>
parents: 15928
diff changeset
337 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
338 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
339 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
340 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
341 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
342
176872829dc2 patch 8.1.1035: prop_remove() second argument is not optional
Bram Moolenaar <Bram@vim.org>
parents: 15928
diff changeset
343 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
344 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
345 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
346 endfor
15138
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
347
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
348 " 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
349 let before_props = deepcopy(props)
15138
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
350 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
351
176872829dc2 patch 8.1.1035: prop_remove() second argument is not optional
Bram Moolenaar <Bram@vim.org>
parents: 15928
diff changeset
352 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
353 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
354 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
355 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
356 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
357
176872829dc2 patch 8.1.1035: prop_remove() second argument is not optional
Bram Moolenaar <Bram@vim.org>
parents: 15928
diff changeset
358 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
359 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
360 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
361 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
362 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
363
176872829dc2 patch 8.1.1035: prop_remove() second argument is not optional
Bram Moolenaar <Bram@vim.org>
parents: 15928
diff changeset
364 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
365 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
366 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
367 endfor
15138
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
368
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
369 call DeletePropTypes()
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
370 wincmd w
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
371 bwipe!
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
372 endfunc
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
373
15347
f6b522596993 patch 8.1.0681: text properties as not adjusted for deleted text
Bram Moolenaar <Bram@vim.org>
parents: 15341
diff changeset
374 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
375 new
f6b522596993 patch 8.1.0681: text properties as not adjusted for deleted text
Bram Moolenaar <Bram@vim.org>
parents: 15341
diff changeset
376 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
377 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
378
f6b522596993 patch 8.1.0681: text properties as not adjusted for deleted text
Bram Moolenaar <Bram@vim.org>
parents: 15341
diff changeset
379 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
380 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
381 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
382 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
383 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
384
f6b522596993 patch 8.1.0681: text properties as not adjusted for deleted text
Bram Moolenaar <Bram@vim.org>
parents: 15341
diff changeset
385 call DeletePropTypes()
f6b522596993 patch 8.1.0681: text properties as not adjusted for deleted text
Bram Moolenaar <Bram@vim.org>
parents: 15341
diff changeset
386 bwipe!
f6b522596993 patch 8.1.0681: text properties as not adjusted for deleted text
Bram Moolenaar <Bram@vim.org>
parents: 15341
diff changeset
387 set bs&
f6b522596993 patch 8.1.0681: text properties as not adjusted for deleted text
Bram Moolenaar <Bram@vim.org>
parents: 15341
diff changeset
388 endfunc
15138
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
389
15349
6abee072b93c patch 8.1.0682: text properties not adjusted when backspacing replaced text
Bram Moolenaar <Bram@vim.org>
parents: 15347
diff changeset
390 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
391 new
6abee072b93c patch 8.1.0682: text properties not adjusted when backspacing replaced text
Bram Moolenaar <Bram@vim.org>
parents: 15347
diff changeset
392 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
393 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
394
6abee072b93c patch 8.1.0682: text properties not adjusted when backspacing replaced text
Bram Moolenaar <Bram@vim.org>
parents: 15347
diff changeset
395 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
396 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
397 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
398
6abee072b93c patch 8.1.0682: text properties not adjusted when backspacing replaced text
Bram Moolenaar <Bram@vim.org>
parents: 15347
diff changeset
399 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
400 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
401 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
402
6abee072b93c patch 8.1.0682: text properties not adjusted when backspacing replaced text
Bram Moolenaar <Bram@vim.org>
parents: 15347
diff changeset
403 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
404 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
405 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
406
6abee072b93c patch 8.1.0682: text properties not adjusted when backspacing replaced text
Bram Moolenaar <Bram@vim.org>
parents: 15347
diff changeset
407 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
408 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
409 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
410
6abee072b93c patch 8.1.0682: text properties not adjusted when backspacing replaced text
Bram Moolenaar <Bram@vim.org>
parents: 15347
diff changeset
411 call DeletePropTypes()
6abee072b93c patch 8.1.0682: text properties not adjusted when backspacing replaced text
Bram Moolenaar <Bram@vim.org>
parents: 15347
diff changeset
412 bwipe!
6abee072b93c patch 8.1.0682: text properties not adjusted when backspacing replaced text
Bram Moolenaar <Bram@vim.org>
parents: 15347
diff changeset
413 set bs&
6abee072b93c patch 8.1.0682: text properties not adjusted when backspacing replaced text
Bram Moolenaar <Bram@vim.org>
parents: 15347
diff changeset
414 endfunc
6abee072b93c patch 8.1.0682: text properties not adjusted when backspacing replaced text
Bram Moolenaar <Bram@vim.org>
parents: 15347
diff changeset
415
16662
1fc9cd08cf3c patch 8.1.1333: text properties don't always move after changes
Bram Moolenaar <Bram@vim.org>
parents: 16545
diff changeset
416 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
417 new
1fc9cd08cf3c patch 8.1.1333: text properties don't always move after changes
Bram Moolenaar <Bram@vim.org>
parents: 16545
diff changeset
418
1fc9cd08cf3c patch 8.1.1333: text properties don't always move after changes
Bram Moolenaar <Bram@vim.org>
parents: 16545
diff changeset
419 " 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
420 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
421 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
422 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
423 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
424 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
425 call DeletePropTypes()
1fc9cd08cf3c patch 8.1.1333: text properties don't always move after changes
Bram Moolenaar <Bram@vim.org>
parents: 16545
diff changeset
426
1fc9cd08cf3c patch 8.1.1333: text properties don't always move after changes
Bram Moolenaar <Bram@vim.org>
parents: 16545
diff changeset
427 " 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
428 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
429 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
430 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
431 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
432 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
433 call DeletePropTypes()
1fc9cd08cf3c patch 8.1.1333: text properties don't always move after changes
Bram Moolenaar <Bram@vim.org>
parents: 16545
diff changeset
434
1fc9cd08cf3c patch 8.1.1333: text properties don't always move after changes
Bram Moolenaar <Bram@vim.org>
parents: 16545
diff changeset
435 " 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
436 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
437 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
438 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
439 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
440 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
441 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
442 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
443 call DeletePropTypes()
1fc9cd08cf3c patch 8.1.1333: text properties don't always move after changes
Bram Moolenaar <Bram@vim.org>
parents: 16545
diff changeset
444
1fc9cd08cf3c patch 8.1.1333: text properties don't always move after changes
Bram Moolenaar <Bram@vim.org>
parents: 16545
diff changeset
445 " 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
446 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
447 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
448 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
449 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
450 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
451 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
452 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
453 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
454 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
455 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
456 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
457 call DeletePropTypes()
1fc9cd08cf3c patch 8.1.1333: text properties don't always move after changes
Bram Moolenaar <Bram@vim.org>
parents: 16545
diff changeset
458
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
459 " 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
460 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
461 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
462 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
463 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
464 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
465 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
466 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
467 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
468 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
469 call DeletePropTypes()
1fc9cd08cf3c patch 8.1.1333: text properties don't always move after changes
Bram Moolenaar <Bram@vim.org>
parents: 16545
diff changeset
470
1fc9cd08cf3c patch 8.1.1333: text properties don't always move after changes
Bram Moolenaar <Bram@vim.org>
parents: 16545
diff changeset
471 bwipe!
1fc9cd08cf3c patch 8.1.1333: text properties don't always move after changes
Bram Moolenaar <Bram@vim.org>
parents: 16545
diff changeset
472 set bs&
1fc9cd08cf3c patch 8.1.1333: text properties don't always move after changes
Bram Moolenaar <Bram@vim.org>
parents: 16545
diff changeset
473 endfunc
1fc9cd08cf3c patch 8.1.1333: text properties don't always move after changes
Bram Moolenaar <Bram@vim.org>
parents: 16545
diff changeset
474
15138
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
475 func Test_prop_clear()
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
476 new
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
477 call AddPropTypes()
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
478 call SetupPropsInFirstLine()
15367
273649cad196 patch 8.1.0691: text properties are not adjusted for :substitute
Bram Moolenaar <Bram@vim.org>
parents: 15365
diff changeset
479 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
480
17980
52f23198af7f patch 8.1.1986: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17694
diff changeset
481 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
482 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
483
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
484 call DeletePropTypes()
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
485 bwipe!
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
486 endfunc
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
487
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
488 func Test_prop_clear_buf()
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
489 new
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
490 call AddPropTypes()
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
491 call SetupPropsInFirstLine()
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
492 let bufnr = bufnr('')
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
493 wincmd w
15367
273649cad196 patch 8.1.0691: text properties are not adjusted for :substitute
Bram Moolenaar <Bram@vim.org>
parents: 15365
diff changeset
494 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
495
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
496 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
497 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
498
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
499 wincmd w
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
500 call DeletePropTypes()
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
501 bwipe!
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
502 endfunc
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
503
15365
01ee8dc12313 patch 8.1.0690: setline() and setbufline() do not clear text properties
Bram Moolenaar <Bram@vim.org>
parents: 15363
diff changeset
504 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
505 new
01ee8dc12313 patch 8.1.0690: setline() and setbufline() do not clear text properties
Bram Moolenaar <Bram@vim.org>
parents: 15363
diff changeset
506 call AddPropTypes()
01ee8dc12313 patch 8.1.0690: setline() and setbufline() do not clear text properties
Bram Moolenaar <Bram@vim.org>
parents: 15363
diff changeset
507 call SetupPropsInFirstLine()
15367
273649cad196 patch 8.1.0691: text properties are not adjusted for :substitute
Bram Moolenaar <Bram@vim.org>
parents: 15365
diff changeset
508 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
509
01ee8dc12313 patch 8.1.0690: setline() and setbufline() do not clear text properties
Bram Moolenaar <Bram@vim.org>
parents: 15363
diff changeset
510 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
511 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
512
01ee8dc12313 patch 8.1.0690: setline() and setbufline() do not clear text properties
Bram Moolenaar <Bram@vim.org>
parents: 15363
diff changeset
513 call DeletePropTypes()
01ee8dc12313 patch 8.1.0690: setline() and setbufline() do not clear text properties
Bram Moolenaar <Bram@vim.org>
parents: 15363
diff changeset
514 bwipe!
01ee8dc12313 patch 8.1.0690: setline() and setbufline() do not clear text properties
Bram Moolenaar <Bram@vim.org>
parents: 15363
diff changeset
515 endfunc
01ee8dc12313 patch 8.1.0690: setline() and setbufline() do not clear text properties
Bram Moolenaar <Bram@vim.org>
parents: 15363
diff changeset
516
01ee8dc12313 patch 8.1.0690: setline() and setbufline() do not clear text properties
Bram Moolenaar <Bram@vim.org>
parents: 15363
diff changeset
517 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
518 new
01ee8dc12313 patch 8.1.0690: setline() and setbufline() do not clear text properties
Bram Moolenaar <Bram@vim.org>
parents: 15363
diff changeset
519 call AddPropTypes()
01ee8dc12313 patch 8.1.0690: setline() and setbufline() do not clear text properties
Bram Moolenaar <Bram@vim.org>
parents: 15363
diff changeset
520 call SetupPropsInFirstLine()
01ee8dc12313 patch 8.1.0690: setline() and setbufline() do not clear text properties
Bram Moolenaar <Bram@vim.org>
parents: 15363
diff changeset
521 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
522 wincmd w
15367
273649cad196 patch 8.1.0691: text properties are not adjusted for :substitute
Bram Moolenaar <Bram@vim.org>
parents: 15365
diff changeset
523 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
524
01ee8dc12313 patch 8.1.0690: setline() and setbufline() do not clear text properties
Bram Moolenaar <Bram@vim.org>
parents: 15363
diff changeset
525 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
526 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
527
01ee8dc12313 patch 8.1.0690: setline() and setbufline() do not clear text properties
Bram Moolenaar <Bram@vim.org>
parents: 15363
diff changeset
528 wincmd w
01ee8dc12313 patch 8.1.0690: setline() and setbufline() do not clear text properties
Bram Moolenaar <Bram@vim.org>
parents: 15363
diff changeset
529 call DeletePropTypes()
01ee8dc12313 patch 8.1.0690: setline() and setbufline() do not clear text properties
Bram Moolenaar <Bram@vim.org>
parents: 15363
diff changeset
530 bwipe!
01ee8dc12313 patch 8.1.0690: setline() and setbufline() do not clear text properties
Bram Moolenaar <Bram@vim.org>
parents: 15363
diff changeset
531 endfunc
01ee8dc12313 patch 8.1.0690: setline() and setbufline() do not clear text properties
Bram Moolenaar <Bram@vim.org>
parents: 15363
diff changeset
532
15367
273649cad196 patch 8.1.0691: text properties are not adjusted for :substitute
Bram Moolenaar <Bram@vim.org>
parents: 15365
diff changeset
533 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
534 new
273649cad196 patch 8.1.0691: text properties are not adjusted for :substitute
Bram Moolenaar <Bram@vim.org>
parents: 15365
diff changeset
535 " 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
536 call AddPropTypes()
273649cad196 patch 8.1.0691: text properties are not adjusted for :substitute
Bram Moolenaar <Bram@vim.org>
parents: 15365
diff changeset
537 call SetupPropsInFirstLine()
273649cad196 patch 8.1.0691: text properties are not adjusted for :substitute
Bram Moolenaar <Bram@vim.org>
parents: 15365
diff changeset
538 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
539 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
540
273649cad196 patch 8.1.0691: text properties are not adjusted for :substitute
Bram Moolenaar <Bram@vim.org>
parents: 15365
diff changeset
541 " 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
542 s/n/XX/
273649cad196 patch 8.1.0691: text properties are not adjusted for :substitute
Bram Moolenaar <Bram@vim.org>
parents: 15365
diff changeset
543 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
544 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
545 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
546 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
547 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
548
273649cad196 patch 8.1.0691: text properties are not adjusted for :substitute
Bram Moolenaar <Bram@vim.org>
parents: 15365
diff changeset
549 " 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
550 s/t//g
273649cad196 patch 8.1.0691: text properties are not adjusted for :substitute
Bram Moolenaar <Bram@vim.org>
parents: 15365
diff changeset
551 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
552 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
553 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
554 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
555 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
556
273649cad196 patch 8.1.0691: text properties are not adjusted for :substitute
Bram Moolenaar <Bram@vim.org>
parents: 15365
diff changeset
557 " 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
558 " 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
559 " 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
560 s/w/\r/
273649cad196 patch 8.1.0691: text properties are not adjusted for :substitute
Bram Moolenaar <Bram@vim.org>
parents: 15365
diff changeset
561 let new_props = [
273649cad196 patch 8.1.0691: text properties are not adjusted for :substitute
Bram Moolenaar <Bram@vim.org>
parents: 15365
diff changeset
562 \ 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
563 \ 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
564 \ 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
565 \ ]
273649cad196 patch 8.1.0691: text properties are not adjusted for :substitute
Bram Moolenaar <Bram@vim.org>
parents: 15365
diff changeset
566 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
567 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
568 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
569 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
570
273649cad196 patch 8.1.0691: text properties are not adjusted for :substitute
Bram Moolenaar <Bram@vim.org>
parents: 15365
diff changeset
571 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
572 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
573 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
574 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
575 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
576
273649cad196 patch 8.1.0691: text properties are not adjusted for :substitute
Bram Moolenaar <Bram@vim.org>
parents: 15365
diff changeset
577 call DeletePropTypes()
273649cad196 patch 8.1.0691: text properties are not adjusted for :substitute
Bram Moolenaar <Bram@vim.org>
parents: 15365
diff changeset
578 bwipe!
273649cad196 patch 8.1.0691: text properties are not adjusted for :substitute
Bram Moolenaar <Bram@vim.org>
parents: 15365
diff changeset
579 endfunc
273649cad196 patch 8.1.0691: text properties are not adjusted for :substitute
Bram Moolenaar <Bram@vim.org>
parents: 15365
diff changeset
580
15398
3e02464faaac patch 8.1.0707: text property columns are not adjusted for changed indent
Bram Moolenaar <Bram@vim.org>
parents: 15367
diff changeset
581 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
582 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
583 new
3e02464faaac patch 8.1.0707: text property columns are not adjusted for changed indent
Bram Moolenaar <Bram@vim.org>
parents: 15367
diff changeset
584 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
585 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
586 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
587 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
588
3e02464faaac patch 8.1.0707: text property columns are not adjusted for changed indent
Bram Moolenaar <Bram@vim.org>
parents: 15367
diff changeset
589 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
590 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
591 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
592 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
593 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
594
3e02464faaac patch 8.1.0707: text property columns are not adjusted for changed indent
Bram Moolenaar <Bram@vim.org>
parents: 15367
diff changeset
595 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
596 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
597 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
598 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
599
3e02464faaac patch 8.1.0707: text property columns are not adjusted for changed indent
Bram Moolenaar <Bram@vim.org>
parents: 15367
diff changeset
600 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
601 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
602 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
603 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
604 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
605
3e02464faaac patch 8.1.0707: text property columns are not adjusted for changed indent
Bram Moolenaar <Bram@vim.org>
parents: 15367
diff changeset
606 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
607 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
608 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
609 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
610
3e02464faaac patch 8.1.0707: text property columns are not adjusted for changed indent
Bram Moolenaar <Bram@vim.org>
parents: 15367
diff changeset
611 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
612 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
613 endfunc
3e02464faaac patch 8.1.0707: text property columns are not adjusted for changed indent
Bram Moolenaar <Bram@vim.org>
parents: 15367
diff changeset
614
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
615 " 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
616 " 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
617 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
618 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
619 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
620 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
621 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
622 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
623 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
624
15251
17525ca95e1e patch 8.1.0634: text properties cannot cross line boundaries
Bram Moolenaar <Bram@vim.org>
parents: 15138
diff changeset
625 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
626 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
627 new
17525ca95e1e patch 8.1.0634: text properties cannot cross line boundaries
Bram Moolenaar <Bram@vim.org>
parents: 15138
diff changeset
628 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
629
17525ca95e1e patch 8.1.0634: text properties cannot cross line boundaries
Bram Moolenaar <Bram@vim.org>
parents: 15138
diff changeset
630 " 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
631 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
632 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
633 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
634 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
635 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
636 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
637 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
638 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
639
17525ca95e1e patch 8.1.0634: text properties cannot cross line boundaries
Bram Moolenaar <Bram@vim.org>
parents: 15138
diff changeset
640 " include all three lines
17525ca95e1e patch 8.1.0634: text properties cannot cross line boundaries
Bram Moolenaar <Bram@vim.org>
parents: 15138
diff changeset
641 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
642 let expect1.col = 1
17525ca95e1e patch 8.1.0634: text properties cannot cross line boundaries
Bram Moolenaar <Bram@vim.org>
parents: 15138
diff changeset
643 let expect1.length = 8
17525ca95e1e patch 8.1.0634: text properties cannot cross line boundaries
Bram Moolenaar <Bram@vim.org>
parents: 15138
diff changeset
644 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
645 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
646 let expect3.length = 9
17525ca95e1e patch 8.1.0634: text properties cannot cross line boundaries
Bram Moolenaar <Bram@vim.org>
parents: 15138
diff changeset
647 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
648 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
649
17525ca95e1e patch 8.1.0634: text properties cannot cross line boundaries
Bram Moolenaar <Bram@vim.org>
parents: 15138
diff changeset
650 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
651
15335
18c20ceee4b5 patch 8.1.0675: text property column in screen columns is not practical
Bram Moolenaar <Bram@vim.org>
parents: 15318
diff changeset
652 " 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
653 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
654 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
655 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
656 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
657 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
658 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
659 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
660 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
661 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
662 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
663
15335
18c20ceee4b5 patch 8.1.0675: text property column in screen columns is not practical
Bram Moolenaar <Bram@vim.org>
parents: 15318
diff changeset
664 " 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
665 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
666 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
667 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
668 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
669 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
670 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
671 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
672 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
673 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
674 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
675
15335
18c20ceee4b5 patch 8.1.0675: text property column in screen columns is not practical
Bram Moolenaar <Bram@vim.org>
parents: 15318
diff changeset
676 " 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
677 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
678 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
679 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
680 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
681 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
682 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
683 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
684 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
685
15251
17525ca95e1e patch 8.1.0634: text properties cannot cross line boundaries
Bram Moolenaar <Bram@vim.org>
parents: 15138
diff changeset
686 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
687 endfunc
17525ca95e1e patch 8.1.0634: text properties cannot cross line boundaries
Bram Moolenaar <Bram@vim.org>
parents: 15138
diff changeset
688
19110
e40814841406 patch 8.2.0115: byte2line() does not work correctly with text properties
Bram Moolenaar <Bram@vim.org>
parents: 19100
diff changeset
689 func Test_prop_line2byte()
15255
19e79a1ed6b6 patch 8.1.0636: line2byte() gives wrong values with text properties
Bram Moolenaar <Bram@vim.org>
parents: 15251
diff changeset
690 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
691 new
15269
27783a6f430b patch 8.1.0643: computing byte offset wrong
Bram Moolenaar <Bram@vim.org>
parents: 15261
diff changeset
692 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
693 set ff=unix
15269
27783a6f430b patch 8.1.0643: computing byte offset wrong
Bram Moolenaar <Bram@vim.org>
parents: 15261
diff changeset
694 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
695 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
696 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
697
19e79a1ed6b6 patch 8.1.0636: line2byte() gives wrong values with text properties
Bram Moolenaar <Bram@vim.org>
parents: 15251
diff changeset
698 bwipe!
19e79a1ed6b6 patch 8.1.0636: line2byte() gives wrong values with text properties
Bram Moolenaar <Bram@vim.org>
parents: 15251
diff changeset
699 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
700 endfunc
19e79a1ed6b6 patch 8.1.0636: line2byte() gives wrong values with text properties
Bram Moolenaar <Bram@vim.org>
parents: 15251
diff changeset
701
19110
e40814841406 patch 8.2.0115: byte2line() does not work correctly with text properties
Bram Moolenaar <Bram@vim.org>
parents: 19100
diff changeset
702 func Test_prop_byte2line()
e40814841406 patch 8.2.0115: byte2line() does not work correctly with text properties
Bram Moolenaar <Bram@vim.org>
parents: 19100
diff changeset
703 new
e40814841406 patch 8.2.0115: byte2line() does not work correctly with text properties
Bram Moolenaar <Bram@vim.org>
parents: 19100
diff changeset
704 set ff=unix
e40814841406 patch 8.2.0115: byte2line() does not work correctly with text properties
Bram Moolenaar <Bram@vim.org>
parents: 19100
diff changeset
705 call setline(1, ['one one', 'two two', 'three three', 'four four', 'five'])
e40814841406 patch 8.2.0115: byte2line() does not work correctly with text properties
Bram Moolenaar <Bram@vim.org>
parents: 19100
diff changeset
706 call assert_equal(4, byte2line(line2byte(4)))
e40814841406 patch 8.2.0115: byte2line() does not work correctly with text properties
Bram Moolenaar <Bram@vim.org>
parents: 19100
diff changeset
707 call assert_equal(5, byte2line(line2byte(5)))
e40814841406 patch 8.2.0115: byte2line() does not work correctly with text properties
Bram Moolenaar <Bram@vim.org>
parents: 19100
diff changeset
708
e40814841406 patch 8.2.0115: byte2line() does not work correctly with text properties
Bram Moolenaar <Bram@vim.org>
parents: 19100
diff changeset
709 call prop_type_add('prop', {'highlight': 'Directory'})
e40814841406 patch 8.2.0115: byte2line() does not work correctly with text properties
Bram Moolenaar <Bram@vim.org>
parents: 19100
diff changeset
710 call prop_add(3, 1, {'length': 5, 'type': 'prop'})
e40814841406 patch 8.2.0115: byte2line() does not work correctly with text properties
Bram Moolenaar <Bram@vim.org>
parents: 19100
diff changeset
711 call assert_equal(4, byte2line(line2byte(4)))
e40814841406 patch 8.2.0115: byte2line() does not work correctly with text properties
Bram Moolenaar <Bram@vim.org>
parents: 19100
diff changeset
712 call assert_equal(5, byte2line(line2byte(5)))
e40814841406 patch 8.2.0115: byte2line() does not work correctly with text properties
Bram Moolenaar <Bram@vim.org>
parents: 19100
diff changeset
713
e40814841406 patch 8.2.0115: byte2line() does not work correctly with text properties
Bram Moolenaar <Bram@vim.org>
parents: 19100
diff changeset
714 bwipe!
e40814841406 patch 8.2.0115: byte2line() does not work correctly with text properties
Bram Moolenaar <Bram@vim.org>
parents: 19100
diff changeset
715 call prop_type_delete('prop')
e40814841406 patch 8.2.0115: byte2line() does not work correctly with text properties
Bram Moolenaar <Bram@vim.org>
parents: 19100
diff changeset
716 endfunc
e40814841406 patch 8.2.0115: byte2line() does not work correctly with text properties
Bram Moolenaar <Bram@vim.org>
parents: 19100
diff changeset
717
15363
45f36b66a032 patch 8.1.0689: undo with text properties not tested
Bram Moolenaar <Bram@vim.org>
parents: 15349
diff changeset
718 func Test_prop_undo()
45f36b66a032 patch 8.1.0689: undo with text properties not tested
Bram Moolenaar <Bram@vim.org>
parents: 15349
diff changeset
719 new
45f36b66a032 patch 8.1.0689: undo with text properties not tested
Bram Moolenaar <Bram@vim.org>
parents: 15349
diff changeset
720 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
721 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
722 " 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
723 set ul&
45f36b66a032 patch 8.1.0689: undo with text properties not tested
Bram Moolenaar <Bram@vim.org>
parents: 15349
diff changeset
724
45f36b66a032 patch 8.1.0689: undo with text properties not tested
Bram Moolenaar <Bram@vim.org>
parents: 15349
diff changeset
725 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
726 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
727 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
728
45f36b66a032 patch 8.1.0689: undo with text properties not tested
Bram Moolenaar <Bram@vim.org>
parents: 15349
diff changeset
729 " 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
730 exe "normal 0lllix\<Esc>"
45f36b66a032 patch 8.1.0689: undo with text properties not tested
Bram Moolenaar <Bram@vim.org>
parents: 15349
diff changeset
731 set ul&
45f36b66a032 patch 8.1.0689: undo with text properties not tested
Bram Moolenaar <Bram@vim.org>
parents: 15349
diff changeset
732 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
733 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
734 undo
45f36b66a032 patch 8.1.0689: undo with text properties not tested
Bram Moolenaar <Bram@vim.org>
parents: 15349
diff changeset
735 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
736 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
737
45f36b66a032 patch 8.1.0689: undo with text properties not tested
Bram Moolenaar <Bram@vim.org>
parents: 15349
diff changeset
738 " 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
739 exe "normal 0lllx"
45f36b66a032 patch 8.1.0689: undo with text properties not tested
Bram Moolenaar <Bram@vim.org>
parents: 15349
diff changeset
740 set ul&
45f36b66a032 patch 8.1.0689: undo with text properties not tested
Bram Moolenaar <Bram@vim.org>
parents: 15349
diff changeset
741 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
742 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
743 undo
45f36b66a032 patch 8.1.0689: undo with text properties not tested
Bram Moolenaar <Bram@vim.org>
parents: 15349
diff changeset
744 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
745 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
746
45f36b66a032 patch 8.1.0689: undo with text properties not tested
Bram Moolenaar <Bram@vim.org>
parents: 15349
diff changeset
747 " 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
748 1d
45f36b66a032 patch 8.1.0689: undo with text properties not tested
Bram Moolenaar <Bram@vim.org>
parents: 15349
diff changeset
749 set ul&
45f36b66a032 patch 8.1.0689: undo with text properties not tested
Bram Moolenaar <Bram@vim.org>
parents: 15349
diff changeset
750 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
751 undo
45f36b66a032 patch 8.1.0689: undo with text properties not tested
Bram Moolenaar <Bram@vim.org>
parents: 15349
diff changeset
752 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
753
45f36b66a032 patch 8.1.0689: undo with text properties not tested
Bram Moolenaar <Bram@vim.org>
parents: 15349
diff changeset
754 " 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
755 exe "normal 0lllix\<Esc>"
45f36b66a032 patch 8.1.0689: undo with text properties not tested
Bram Moolenaar <Bram@vim.org>
parents: 15349
diff changeset
756 set ul&
45f36b66a032 patch 8.1.0689: undo with text properties not tested
Bram Moolenaar <Bram@vim.org>
parents: 15349
diff changeset
757 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
758 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
759 exe "normal 0lllxx"
45f36b66a032 patch 8.1.0689: undo with text properties not tested
Bram Moolenaar <Bram@vim.org>
parents: 15349
diff changeset
760 set ul&
45f36b66a032 patch 8.1.0689: undo with text properties not tested
Bram Moolenaar <Bram@vim.org>
parents: 15349
diff changeset
761 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
762 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
763 normal U
45f36b66a032 patch 8.1.0689: undo with text properties not tested
Bram Moolenaar <Bram@vim.org>
parents: 15349
diff changeset
764 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
765 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
766
16698
23af483c4ceb patch 8.1.1351: text property wrong after :substitute
Bram Moolenaar <Bram@vim.org>
parents: 16682
diff changeset
767 " substitute a word, then undo
23af483c4ceb patch 8.1.1351: text property wrong after :substitute
Bram Moolenaar <Bram@vim.org>
parents: 16682
diff changeset
768 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
769 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
770 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
771 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
772 set ul&
23af483c4ceb patch 8.1.1351: text property wrong after :substitute
Bram Moolenaar <Bram@vim.org>
parents: 16682
diff changeset
773 1s/number/foo
23af483c4ceb patch 8.1.1351: text property wrong after :substitute
Bram Moolenaar <Bram@vim.org>
parents: 16682
diff changeset
774 let expected[0].col = 9
23af483c4ceb patch 8.1.1351: text property wrong after :substitute
Bram Moolenaar <Bram@vim.org>
parents: 16682
diff changeset
775 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
776 undo
23af483c4ceb patch 8.1.1351: text property wrong after :substitute
Bram Moolenaar <Bram@vim.org>
parents: 16682
diff changeset
777 let expected[0].col = 12
23af483c4ceb patch 8.1.1351: text property wrong after :substitute
Bram Moolenaar <Bram@vim.org>
parents: 16682
diff changeset
778 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
779 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
780
ba592f30c082 patch 8.1.1359: text property wrong after :substitute with backslash
Bram Moolenaar <Bram@vim.org>
parents: 16698
diff changeset
781 " substitute with backslash
ba592f30c082 patch 8.1.1359: text property wrong after :substitute with backslash
Bram Moolenaar <Bram@vim.org>
parents: 16698
diff changeset
782 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
783 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
784 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
785 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
786 1s/the/\The
ba592f30c082 patch 8.1.1359: text property wrong after :substitute with backslash
Bram Moolenaar <Bram@vim.org>
parents: 16698
diff changeset
787 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
788 1s/^/\\
ba592f30c082 patch 8.1.1359: text property wrong after :substitute with backslash
Bram Moolenaar <Bram@vim.org>
parents: 16698
diff changeset
789 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
790 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
791 1s/^/\~
ba592f30c082 patch 8.1.1359: text property wrong after :substitute with backslash
Bram Moolenaar <Bram@vim.org>
parents: 16698
diff changeset
792 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
793 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
794 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
795 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
796 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
797 call prop_clear(1)
16698
23af483c4ceb patch 8.1.1351: text property wrong after :substitute
Bram Moolenaar <Bram@vim.org>
parents: 16682
diff changeset
798
15363
45f36b66a032 patch 8.1.0689: undo with text properties not tested
Bram Moolenaar <Bram@vim.org>
parents: 15349
diff changeset
799 bwipe!
45f36b66a032 patch 8.1.0689: undo with text properties not tested
Bram Moolenaar <Bram@vim.org>
parents: 15349
diff changeset
800 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
801 endfunc
45f36b66a032 patch 8.1.0689: undo with text properties not tested
Bram Moolenaar <Bram@vim.org>
parents: 15349
diff changeset
802
18631
e2d9f4d030fa patch 8.1.2308: deleting text before zero-width textprop removes it
Bram Moolenaar <Bram@vim.org>
parents: 18605
diff changeset
803 func Test_prop_delete_text()
e2d9f4d030fa patch 8.1.2308: deleting text before zero-width textprop removes it
Bram Moolenaar <Bram@vim.org>
parents: 18605
diff changeset
804 new
e2d9f4d030fa patch 8.1.2308: deleting text before zero-width textprop removes it
Bram Moolenaar <Bram@vim.org>
parents: 18605
diff changeset
805 call prop_type_add('comment', {'highlight': 'Directory'})
e2d9f4d030fa patch 8.1.2308: deleting text before zero-width textprop removes it
Bram Moolenaar <Bram@vim.org>
parents: 18605
diff changeset
806 call setline(1, ['oneone', 'twotwo', 'three'])
e2d9f4d030fa patch 8.1.2308: deleting text before zero-width textprop removes it
Bram Moolenaar <Bram@vim.org>
parents: 18605
diff changeset
807
e2d9f4d030fa patch 8.1.2308: deleting text before zero-width textprop removes it
Bram Moolenaar <Bram@vim.org>
parents: 18605
diff changeset
808 " zero length property
e2d9f4d030fa patch 8.1.2308: deleting text before zero-width textprop removes it
Bram Moolenaar <Bram@vim.org>
parents: 18605
diff changeset
809 call prop_add(1, 3, {'type': 'comment'})
e2d9f4d030fa patch 8.1.2308: deleting text before zero-width textprop removes it
Bram Moolenaar <Bram@vim.org>
parents: 18605
diff changeset
810 let expected = [{'col': 3, 'length': 0, 'id': 0, 'type': 'comment', 'start': 1, 'end': 1} ]
e2d9f4d030fa patch 8.1.2308: deleting text before zero-width textprop removes it
Bram Moolenaar <Bram@vim.org>
parents: 18605
diff changeset
811 call assert_equal(expected, prop_list(1))
e2d9f4d030fa patch 8.1.2308: deleting text before zero-width textprop removes it
Bram Moolenaar <Bram@vim.org>
parents: 18605
diff changeset
812
e2d9f4d030fa patch 8.1.2308: deleting text before zero-width textprop removes it
Bram Moolenaar <Bram@vim.org>
parents: 18605
diff changeset
813 " delete one char moves the property
e2d9f4d030fa patch 8.1.2308: deleting text before zero-width textprop removes it
Bram Moolenaar <Bram@vim.org>
parents: 18605
diff changeset
814 normal! x
e2d9f4d030fa patch 8.1.2308: deleting text before zero-width textprop removes it
Bram Moolenaar <Bram@vim.org>
parents: 18605
diff changeset
815 let expected = [{'col': 2, 'length': 0, 'id': 0, 'type': 'comment', 'start': 1, 'end': 1} ]
e2d9f4d030fa patch 8.1.2308: deleting text before zero-width textprop removes it
Bram Moolenaar <Bram@vim.org>
parents: 18605
diff changeset
816 call assert_equal(expected, prop_list(1))
e2d9f4d030fa patch 8.1.2308: deleting text before zero-width textprop removes it
Bram Moolenaar <Bram@vim.org>
parents: 18605
diff changeset
817
e2d9f4d030fa patch 8.1.2308: deleting text before zero-width textprop removes it
Bram Moolenaar <Bram@vim.org>
parents: 18605
diff changeset
818 " delete char of the property has no effect
e2d9f4d030fa patch 8.1.2308: deleting text before zero-width textprop removes it
Bram Moolenaar <Bram@vim.org>
parents: 18605
diff changeset
819 normal! lx
e2d9f4d030fa patch 8.1.2308: deleting text before zero-width textprop removes it
Bram Moolenaar <Bram@vim.org>
parents: 18605
diff changeset
820 let expected = [{'col': 2, 'length': 0, 'id': 0, 'type': 'comment', 'start': 1, 'end': 1} ]
e2d9f4d030fa patch 8.1.2308: deleting text before zero-width textprop removes it
Bram Moolenaar <Bram@vim.org>
parents: 18605
diff changeset
821 call assert_equal(expected, prop_list(1))
e2d9f4d030fa patch 8.1.2308: deleting text before zero-width textprop removes it
Bram Moolenaar <Bram@vim.org>
parents: 18605
diff changeset
822
e2d9f4d030fa patch 8.1.2308: deleting text before zero-width textprop removes it
Bram Moolenaar <Bram@vim.org>
parents: 18605
diff changeset
823 " delete more chars moves property to first column, is not deleted
e2d9f4d030fa patch 8.1.2308: deleting text before zero-width textprop removes it
Bram Moolenaar <Bram@vim.org>
parents: 18605
diff changeset
824 normal! 0xxxx
e2d9f4d030fa patch 8.1.2308: deleting text before zero-width textprop removes it
Bram Moolenaar <Bram@vim.org>
parents: 18605
diff changeset
825 let expected = [{'col': 1, 'length': 0, 'id': 0, 'type': 'comment', 'start': 1, 'end': 1} ]
e2d9f4d030fa patch 8.1.2308: deleting text before zero-width textprop removes it
Bram Moolenaar <Bram@vim.org>
parents: 18605
diff changeset
826 call assert_equal(expected, prop_list(1))
e2d9f4d030fa patch 8.1.2308: deleting text before zero-width textprop removes it
Bram Moolenaar <Bram@vim.org>
parents: 18605
diff changeset
827
e2d9f4d030fa patch 8.1.2308: deleting text before zero-width textprop removes it
Bram Moolenaar <Bram@vim.org>
parents: 18605
diff changeset
828 bwipe!
e2d9f4d030fa patch 8.1.2308: deleting text before zero-width textprop removes it
Bram Moolenaar <Bram@vim.org>
parents: 18605
diff changeset
829 call prop_type_delete('comment')
e2d9f4d030fa patch 8.1.2308: deleting text before zero-width textprop removes it
Bram Moolenaar <Bram@vim.org>
parents: 18605
diff changeset
830 endfunc
e2d9f4d030fa patch 8.1.2308: deleting text before zero-width textprop removes it
Bram Moolenaar <Bram@vim.org>
parents: 18605
diff changeset
831
15314
c4d62945d96f patch 8.1.0665: text property display wrong when 'spell' is set
Bram Moolenaar <Bram@vim.org>
parents: 15294
diff changeset
832 " 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
833 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
834 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
835 " 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
836 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
837 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
838 endif
c4d62945d96f patch 8.1.0665: text property display wrong when 'spell' is set
Bram Moolenaar <Bram@vim.org>
parents: 15294
diff changeset
839 call writefile([
16545
7a563ee902b6 patch 8.1.1276: cannot combine text properties with syntax highlighting
Bram Moolenaar <Bram@vim.org>
parents: 16060
diff changeset
840 \ "call setline(1, ["
7a563ee902b6 patch 8.1.1276: cannot combine text properties with syntax highlighting
Bram Moolenaar <Bram@vim.org>
parents: 16060
diff changeset
841 \ .. "'One two',"
7a563ee902b6 patch 8.1.1276: cannot combine text properties with syntax highlighting
Bram Moolenaar <Bram@vim.org>
parents: 16060
diff changeset
842 \ .. "'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
843 \ .. "'--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
844 \ .. "'// 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
845 \ .. "'first line',"
6f453673eb19 patch 8.1.1341: text properties are lost when joining lines
Bram Moolenaar <Bram@vim.org>
parents: 16676
diff changeset
846 \ .. "' second line ',"
6f453673eb19 patch 8.1.1341: text properties are lost when joining lines
Bram Moolenaar <Bram@vim.org>
parents: 16676
diff changeset
847 \ .. "'third line',"
6f453673eb19 patch 8.1.1341: text properties are lost when joining lines
Bram Moolenaar <Bram@vim.org>
parents: 16676
diff changeset
848 \ .. "' fourth line',"
16545
7a563ee902b6 patch 8.1.1276: cannot combine text properties with syntax highlighting
Bram Moolenaar <Bram@vim.org>
parents: 16060
diff changeset
849 \ .. "])",
15314
c4d62945d96f patch 8.1.0665: text property display wrong when 'spell' is set
Bram Moolenaar <Bram@vim.org>
parents: 15294
diff changeset
850 \ "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
851 \ "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
852 \ "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
853 \ "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
854 \ "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
855 \ "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
856 \ "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
857 \ "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
858 \ "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
859 \ "call prop_type_add('both', {'highlight': 'NumberProp', 'start_incl': 1, 'end_incl': 1})",
18570
0ac88fdbf089 patch 8.1.2279: computation of highlight attributes is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 18444
diff changeset
860 \ "call prop_type_add('background', {'highlight': 'BackgroundProp', 'combine': 0})",
0ac88fdbf089 patch 8.1.2279: computation of highlight attributes is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 18444
diff changeset
861 \ "call prop_type_add('backgroundcomb', {'highlight': 'NumberProp', 'combine': 1})",
0ac88fdbf089 patch 8.1.2279: computation of highlight attributes is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 18444
diff changeset
862 \ "eval 'backgroundcomb'->prop_type_change({'highlight': 'BackgroundProp'})",
18605
63d855ad505c patch 8.1.2296: text properties are not combined with syntax by default
Bram Moolenaar <Bram@vim.org>
parents: 18570
diff changeset
863 \ "call prop_type_add('error', {'highlight': 'UnderlineProp'})",
15314
c4d62945d96f patch 8.1.0665: text property display wrong when 'spell' is set
Bram Moolenaar <Bram@vim.org>
parents: 15294
diff changeset
864 \ "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
865 \ "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
866 \ "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
867 \ "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
868 \ "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
869 \ "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
870 \ "call prop_add(3, 15, {'length': 2, 'type': 'both'})",
18570
0ac88fdbf089 patch 8.1.2279: computation of highlight attributes is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 18444
diff changeset
871 \ "call prop_add(4, 6, {'length': 3, 'type': 'background'})",
0ac88fdbf089 patch 8.1.2279: computation of highlight attributes is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 18444
diff changeset
872 \ "call prop_add(4, 12, {'length': 10, 'type': 'backgroundcomb'})",
16545
7a563ee902b6 patch 8.1.1276: cannot combine text properties with syntax highlighting
Bram Moolenaar <Bram@vim.org>
parents: 16060
diff changeset
873 \ "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
874 \ "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
875 \ "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
876 \ "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
877 \ "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
878 \ "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
879 \ "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
880 \ "set spell",
16545
7a563ee902b6 patch 8.1.1276: cannot combine text properties with syntax highlighting
Bram Moolenaar <Bram@vim.org>
parents: 16060
diff changeset
881 \ "syn match Comment '//.*'",
7a563ee902b6 patch 8.1.1276: cannot combine text properties with syntax highlighting
Bram Moolenaar <Bram@vim.org>
parents: 16060
diff changeset
882 \ "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
883 \ "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
884 \ "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
885 \ "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
886 \ "normal 3J",
6f453673eb19 patch 8.1.1341: text properties are lost when joining lines
Bram Moolenaar <Bram@vim.org>
parents: 16676
diff changeset
887 \ "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
888 \], 'XtestProp')
16678
6f453673eb19 patch 8.1.1341: text properties are lost when joining lines
Bram Moolenaar <Bram@vim.org>
parents: 16676
diff changeset
889 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
890 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
891
15314
c4d62945d96f patch 8.1.0665: text property display wrong when 'spell' is set
Bram Moolenaar <Bram@vim.org>
parents: 15294
diff changeset
892 " clean up
c4d62945d96f patch 8.1.0665: text property display wrong when 'spell' is set
Bram Moolenaar <Bram@vim.org>
parents: 15294
diff changeset
893 call StopVimInTerminal(buf)
15318
f58e7895cb40 patch 8.1.0667: textprop test leaves file behind
Bram Moolenaar <Bram@vim.org>
parents: 15314
diff changeset
894 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
895 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
896
7847d281cbbf patch 8.1.1343: text properties not adjusted for Visual block mode delete
Bram Moolenaar <Bram@vim.org>
parents: 16678
diff changeset
897 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
898 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
899 \ "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
900 \ .. "'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
901 \ .. "'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
902 \ .. "'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
903 \ .. "'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
904 \ .. "'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
905 \ .. "'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
906 \ .. "'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
907 \ .. "'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
908 \ .. "'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
909 \ .. "' 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
910 \ .. "])",
7847d281cbbf patch 8.1.1343: text properties not adjusted for Visual block mode delete
Bram Moolenaar <Bram@vim.org>
parents: 16678
diff changeset
911 \ "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
912 \ "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
913 \ "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
914 \ "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
915 \ "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
916 \ "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
917 \ "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
918 \ "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
919 \ "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
920 \ "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
921 \ "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
922 \ "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
923 \ "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
924 \], 'XtestPropVis')
7847d281cbbf patch 8.1.1343: text properties not adjusted for Visual block mode delete
Bram Moolenaar <Bram@vim.org>
parents: 16678
diff changeset
925 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
926 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
927
7847d281cbbf patch 8.1.1343: text properties not adjusted for Visual block mode delete
Bram Moolenaar <Bram@vim.org>
parents: 16678
diff changeset
928 " 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
929 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
930 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
931 endfunc
7847d281cbbf patch 8.1.1343: text properties not adjusted for Visual block mode delete
Bram Moolenaar <Bram@vim.org>
parents: 16678
diff changeset
932
7847d281cbbf patch 8.1.1343: text properties not adjusted for Visual block mode delete
Bram Moolenaar <Bram@vim.org>
parents: 16678
diff changeset
933 " 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
934 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
935 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
936
7847d281cbbf patch 8.1.1343: text properties not adjusted for Visual block mode delete
Bram Moolenaar <Bram@vim.org>
parents: 16678
diff changeset
937 " 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
938 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
939
7847d281cbbf patch 8.1.1343: text properties not adjusted for Visual block mode delete
Bram Moolenaar <Bram@vim.org>
parents: 16678
diff changeset
940 " 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
941 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
942 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
943
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
944 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
945 CheckScreendump
17147
a001a0d88d42 patch 8.1.1573: textprop test fails if screenhots do not work
Bram Moolenaar <Bram@vim.org>
parents: 17143
diff changeset
946
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
947 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
948 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
949 \ "\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
950 \ "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
951 \ ])
ee090ecd70f6 patch 8.1.1571: textprop highlight starts too early if just after a tab
Bram Moolenaar <Bram@vim.org>
parents: 17089
diff changeset
952 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
953 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
954 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
955 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
956 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
957 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
958 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
959 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
960
ee090ecd70f6 patch 8.1.1571: textprop highlight starts too early if just after a tab
Bram Moolenaar <Bram@vim.org>
parents: 17089
diff changeset
961 " 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
962 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
963 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
964 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
965
18317
d2228d4cf1f6 patch 8.1.2153: combining text property and syntax highlight is wrong
Bram Moolenaar <Bram@vim.org>
parents: 17980
diff changeset
966 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
967 CheckScreendump
d2228d4cf1f6 patch 8.1.2153: combining text property and syntax highlight is wrong
Bram Moolenaar <Bram@vim.org>
parents: 17980
diff changeset
968
d2228d4cf1f6 patch 8.1.2153: combining text property and syntax highlight is wrong
Bram Moolenaar <Bram@vim.org>
parents: 17980
diff changeset
969 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
970 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
971 \ "(abc)",
d2228d4cf1f6 patch 8.1.2153: combining text property and syntax highlight is wrong
Bram Moolenaar <Bram@vim.org>
parents: 17980
diff changeset
972 \ ])
d2228d4cf1f6 patch 8.1.2153: combining text property and syntax highlight is wrong
Bram Moolenaar <Bram@vim.org>
parents: 17980
diff changeset
973 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
974 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
975
d2228d4cf1f6 patch 8.1.2153: combining text property and syntax highlight is wrong
Bram Moolenaar <Bram@vim.org>
parents: 17980
diff changeset
976 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
977 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
978 END
d2228d4cf1f6 patch 8.1.2153: combining text property and syntax highlight is wrong
Bram Moolenaar <Bram@vim.org>
parents: 17980
diff changeset
979 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
980 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
981 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
982
d2228d4cf1f6 patch 8.1.2153: combining text property and syntax highlight is wrong
Bram Moolenaar <Bram@vim.org>
parents: 17980
diff changeset
983 " clean up
d2228d4cf1f6 patch 8.1.2153: combining text property and syntax highlight is wrong
Bram Moolenaar <Bram@vim.org>
parents: 17980
diff changeset
984 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
985 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
986 endfunc
d2228d4cf1f6 patch 8.1.2153: combining text property and syntax highlight is wrong
Bram Moolenaar <Bram@vim.org>
parents: 17980
diff changeset
987
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
988 " 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
989 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
990 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
991 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
992 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
993 close
16786
98ca522e6453 patch 8.1.1395: saving for undo may access invalid memory
Bram Moolenaar <Bram@vim.org>
parents: 16772
diff changeset
994 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
995 endfunc
98ca522e6453 patch 8.1.1395: saving for undo may access invalid memory
Bram Moolenaar <Bram@vim.org>
parents: 16772
diff changeset
996
17208
13d0753511fe patch 8.1.1603: crash when using unknown highlighting in text property
Bram Moolenaar <Bram@vim.org>
parents: 17147
diff changeset
997 " 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
998 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
999 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
1000 new
13d0753511fe patch 8.1.1603: crash when using unknown highlighting in text property
Bram Moolenaar <Bram@vim.org>
parents: 17147
diff changeset
1001 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
1002 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
1003 redraw
13d0753511fe patch 8.1.1603: crash when using unknown highlighting in text property
Bram Moolenaar <Bram@vim.org>
parents: 17147
diff changeset
1004 bwipe!
13d0753511fe patch 8.1.1603: crash when using unknown highlighting in text property
Bram Moolenaar <Bram@vim.org>
parents: 17147
diff changeset
1005 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
1006 endfunc
13d0753511fe patch 8.1.1603: crash when using unknown highlighting in text property
Bram Moolenaar <Bram@vim.org>
parents: 17147
diff changeset
1007
16786
98ca522e6453 patch 8.1.1395: saving for undo may access invalid memory
Bram Moolenaar <Bram@vim.org>
parents: 16772
diff changeset
1008 " 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
1009 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
1010 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
1011 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
1012 next X
98ca522e6453 patch 8.1.1395: saving for undo may access invalid memory
Bram Moolenaar <Bram@vim.org>
parents: 16772
diff changeset
1013 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
1014 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
1015
18093a6accb5 patch 8.1.1388: errors when calling prop_remove() for an unloaded buffer
Bram Moolenaar <Bram@vim.org>
parents: 16770
diff changeset
1016 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
1017 new
18093a6accb5 patch 8.1.1388: errors when calling prop_remove() for an unloaded buffer
Bram Moolenaar <Bram@vim.org>
parents: 16770
diff changeset
1018 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
1019 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
1020 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
1021 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
1022 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
1023 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
1024 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
1025 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
1026 close
18093a6accb5 patch 8.1.1388: errors when calling prop_remove() for an unloaded buffer
Bram Moolenaar <Bram@vim.org>
parents: 16770
diff changeset
1027 endfunc
17694
6f9cde96ee3c patch 8.1.1844: buffer no longer unloaded when adding text properties
Bram Moolenaar <Bram@vim.org>
parents: 17208
diff changeset
1028
6f9cde96ee3c patch 8.1.1844: buffer no longer unloaded when adding text properties
Bram Moolenaar <Bram@vim.org>
parents: 17208
diff changeset
1029 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
1030 edit Xaaa
6f9cde96ee3c patch 8.1.1844: buffer no longer unloaded when adding text properties
Bram Moolenaar <Bram@vim.org>
parents: 17208
diff changeset
1031 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
1032 write
6f9cde96ee3c patch 8.1.1844: buffer no longer unloaded when adding text properties
Bram Moolenaar <Bram@vim.org>
parents: 17208
diff changeset
1033 edit Xbbb
6f9cde96ee3c patch 8.1.1844: buffer no longer unloaded when adding text properties
Bram Moolenaar <Bram@vim.org>
parents: 17208
diff changeset
1034 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
1035 write
6f9cde96ee3c patch 8.1.1844: buffer no longer unloaded when adding text properties
Bram Moolenaar <Bram@vim.org>
parents: 17208
diff changeset
1036 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
1037 edit Xaaa
6f9cde96ee3c patch 8.1.1844: buffer no longer unloaded when adding text properties
Bram Moolenaar <Bram@vim.org>
parents: 17208
diff changeset
1038
6f9cde96ee3c patch 8.1.1844: buffer no longer unloaded when adding text properties
Bram Moolenaar <Bram@vim.org>
parents: 17208
diff changeset
1039 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
1040 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
1041 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
1042 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
1043 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
1044
6f9cde96ee3c patch 8.1.1844: buffer no longer unloaded when adding text properties
Bram Moolenaar <Bram@vim.org>
parents: 17208
diff changeset
1045 bwipe! Xaaa
6f9cde96ee3c patch 8.1.1844: buffer no longer unloaded when adding text properties
Bram Moolenaar <Bram@vim.org>
parents: 17208
diff changeset
1046 bwipe! Xbbb
6f9cde96ee3c patch 8.1.1844: buffer no longer unloaded when adding text properties
Bram Moolenaar <Bram@vim.org>
parents: 17208
diff changeset
1047 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
1048 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
1049 endfunc
18444
967ca19425e3 patch 8.1.2216: text property in wrong place after :substitute
Bram Moolenaar <Bram@vim.org>
parents: 18317
diff changeset
1050
967ca19425e3 patch 8.1.2216: text property in wrong place after :substitute
Bram Moolenaar <Bram@vim.org>
parents: 18317
diff changeset
1051 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
1052 new
967ca19425e3 patch 8.1.2216: text property in wrong place after :substitute
Bram Moolenaar <Bram@vim.org>
parents: 18317
diff changeset
1053 " text_prop.vim
967ca19425e3 patch 8.1.2216: text property in wrong place after :substitute
Bram Moolenaar <Bram@vim.org>
parents: 18317
diff changeset
1054 call setline(1, [
967ca19425e3 patch 8.1.2216: text property in wrong place after :substitute
Bram Moolenaar <Bram@vim.org>
parents: 18317
diff changeset
1055 \ '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
1056 \ '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
1057 \ '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
1058
967ca19425e3 patch 8.1.2216: text property in wrong place after :substitute
Bram Moolenaar <Bram@vim.org>
parents: 18317
diff changeset
1059 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
1060
967ca19425e3 patch 8.1.2216: text property in wrong place after :substitute
Bram Moolenaar <Bram@vim.org>
parents: 18317
diff changeset
1061 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
1062 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
1063 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
1064 set ul&
967ca19425e3 patch 8.1.2216: text property in wrong place after :substitute
Bram Moolenaar <Bram@vim.org>
parents: 18317
diff changeset
1065 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
1066 \ {'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
1067 \ {'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
1068 " 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
1069 %s/\s\+/ /g
967ca19425e3 patch 8.1.2216: text property in wrong place after :substitute
Bram Moolenaar <Bram@vim.org>
parents: 18317
diff changeset
1070 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
1071
967ca19425e3 patch 8.1.2216: text property in wrong place after :substitute
Bram Moolenaar <Bram@vim.org>
parents: 18317
diff changeset
1072 " remove some text
967ca19425e3 patch 8.1.2216: text property in wrong place after :substitute
Bram Moolenaar <Bram@vim.org>
parents: 18317
diff changeset
1073 :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
1074 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
1075 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
1076 bwipe!
967ca19425e3 patch 8.1.2216: text property in wrong place after :substitute
Bram Moolenaar <Bram@vim.org>
parents: 18317
diff changeset
1077 endfunc
19045
143d44d8f477 patch 8.2.0083: text properties wrong when tabs and spaces are exchanged
Bram Moolenaar <Bram@vim.org>
parents: 18631
diff changeset
1078
19097
bcbc9fe665b5 patch 8.2.0109: corrupted text properties when expanding spaces
Bram Moolenaar <Bram@vim.org>
parents: 19045
diff changeset
1079 func SaveOptions()
bcbc9fe665b5 patch 8.2.0109: corrupted text properties when expanding spaces
Bram Moolenaar <Bram@vim.org>
parents: 19045
diff changeset
1080 let d = #{tabstop: &tabstop,
bcbc9fe665b5 patch 8.2.0109: corrupted text properties when expanding spaces
Bram Moolenaar <Bram@vim.org>
parents: 19045
diff changeset
1081 \ softtabstop: &softtabstop,
bcbc9fe665b5 patch 8.2.0109: corrupted text properties when expanding spaces
Bram Moolenaar <Bram@vim.org>
parents: 19045
diff changeset
1082 \ shiftwidth: &shiftwidth,
bcbc9fe665b5 patch 8.2.0109: corrupted text properties when expanding spaces
Bram Moolenaar <Bram@vim.org>
parents: 19045
diff changeset
1083 \ expandtab: &expandtab,
bcbc9fe665b5 patch 8.2.0109: corrupted text properties when expanding spaces
Bram Moolenaar <Bram@vim.org>
parents: 19045
diff changeset
1084 \ foldmethod: '"' .. &foldmethod .. '"',
bcbc9fe665b5 patch 8.2.0109: corrupted text properties when expanding spaces
Bram Moolenaar <Bram@vim.org>
parents: 19045
diff changeset
1085 \ }
bcbc9fe665b5 patch 8.2.0109: corrupted text properties when expanding spaces
Bram Moolenaar <Bram@vim.org>
parents: 19045
diff changeset
1086 return d
bcbc9fe665b5 patch 8.2.0109: corrupted text properties when expanding spaces
Bram Moolenaar <Bram@vim.org>
parents: 19045
diff changeset
1087 endfunc
bcbc9fe665b5 patch 8.2.0109: corrupted text properties when expanding spaces
Bram Moolenaar <Bram@vim.org>
parents: 19045
diff changeset
1088
bcbc9fe665b5 patch 8.2.0109: corrupted text properties when expanding spaces
Bram Moolenaar <Bram@vim.org>
parents: 19045
diff changeset
1089 func RestoreOptions(dict)
bcbc9fe665b5 patch 8.2.0109: corrupted text properties when expanding spaces
Bram Moolenaar <Bram@vim.org>
parents: 19045
diff changeset
1090 for name in keys(a:dict)
bcbc9fe665b5 patch 8.2.0109: corrupted text properties when expanding spaces
Bram Moolenaar <Bram@vim.org>
parents: 19045
diff changeset
1091 exe 'let &' .. name .. ' = ' .. a:dict[name]
bcbc9fe665b5 patch 8.2.0109: corrupted text properties when expanding spaces
Bram Moolenaar <Bram@vim.org>
parents: 19045
diff changeset
1092 endfor
bcbc9fe665b5 patch 8.2.0109: corrupted text properties when expanding spaces
Bram Moolenaar <Bram@vim.org>
parents: 19045
diff changeset
1093 endfunc
bcbc9fe665b5 patch 8.2.0109: corrupted text properties when expanding spaces
Bram Moolenaar <Bram@vim.org>
parents: 19045
diff changeset
1094
19045
143d44d8f477 patch 8.2.0083: text properties wrong when tabs and spaces are exchanged
Bram Moolenaar <Bram@vim.org>
parents: 18631
diff changeset
1095 func Test_textprop_noexpandtab()
143d44d8f477 patch 8.2.0083: text properties wrong when tabs and spaces are exchanged
Bram Moolenaar <Bram@vim.org>
parents: 18631
diff changeset
1096 new
19097
bcbc9fe665b5 patch 8.2.0109: corrupted text properties when expanding spaces
Bram Moolenaar <Bram@vim.org>
parents: 19045
diff changeset
1097 let save_dict = SaveOptions()
bcbc9fe665b5 patch 8.2.0109: corrupted text properties when expanding spaces
Bram Moolenaar <Bram@vim.org>
parents: 19045
diff changeset
1098
19045
143d44d8f477 patch 8.2.0083: text properties wrong when tabs and spaces are exchanged
Bram Moolenaar <Bram@vim.org>
parents: 18631
diff changeset
1099 set tabstop=8
143d44d8f477 patch 8.2.0083: text properties wrong when tabs and spaces are exchanged
Bram Moolenaar <Bram@vim.org>
parents: 18631
diff changeset
1100 set softtabstop=4
143d44d8f477 patch 8.2.0083: text properties wrong when tabs and spaces are exchanged
Bram Moolenaar <Bram@vim.org>
parents: 18631
diff changeset
1101 set shiftwidth=4
143d44d8f477 patch 8.2.0083: text properties wrong when tabs and spaces are exchanged
Bram Moolenaar <Bram@vim.org>
parents: 18631
diff changeset
1102 set noexpandtab
143d44d8f477 patch 8.2.0083: text properties wrong when tabs and spaces are exchanged
Bram Moolenaar <Bram@vim.org>
parents: 18631
diff changeset
1103 set foldmethod=marker
19097
bcbc9fe665b5 patch 8.2.0109: corrupted text properties when expanding spaces
Bram Moolenaar <Bram@vim.org>
parents: 19045
diff changeset
1104
19045
143d44d8f477 patch 8.2.0083: text properties wrong when tabs and spaces are exchanged
Bram Moolenaar <Bram@vim.org>
parents: 18631
diff changeset
1105 call feedkeys("\<esc>\<esc>0Ca\<cr>\<esc>\<up>", "tx")
143d44d8f477 patch 8.2.0083: text properties wrong when tabs and spaces are exchanged
Bram Moolenaar <Bram@vim.org>
parents: 18631
diff changeset
1106 call prop_type_add('test', {'highlight': 'ErrorMsg'})
143d44d8f477 patch 8.2.0083: text properties wrong when tabs and spaces are exchanged
Bram Moolenaar <Bram@vim.org>
parents: 18631
diff changeset
1107 call prop_add(1, 1, {'end_col': 2, 'type': 'test'})
143d44d8f477 patch 8.2.0083: text properties wrong when tabs and spaces are exchanged
Bram Moolenaar <Bram@vim.org>
parents: 18631
diff changeset
1108 call feedkeys("0i\<tab>", "tx")
143d44d8f477 patch 8.2.0083: text properties wrong when tabs and spaces are exchanged
Bram Moolenaar <Bram@vim.org>
parents: 18631
diff changeset
1109 call prop_remove({'type': 'test'})
143d44d8f477 patch 8.2.0083: text properties wrong when tabs and spaces are exchanged
Bram Moolenaar <Bram@vim.org>
parents: 18631
diff changeset
1110 call prop_add(1, 2, {'end_col': 3, 'type': 'test'})
143d44d8f477 patch 8.2.0083: text properties wrong when tabs and spaces are exchanged
Bram Moolenaar <Bram@vim.org>
parents: 18631
diff changeset
1111 call feedkeys("A\<left>\<tab>", "tx")
143d44d8f477 patch 8.2.0083: text properties wrong when tabs and spaces are exchanged
Bram Moolenaar <Bram@vim.org>
parents: 18631
diff changeset
1112 call prop_remove({'type': 'test'})
143d44d8f477 patch 8.2.0083: text properties wrong when tabs and spaces are exchanged
Bram Moolenaar <Bram@vim.org>
parents: 18631
diff changeset
1113 try
143d44d8f477 patch 8.2.0083: text properties wrong when tabs and spaces are exchanged
Bram Moolenaar <Bram@vim.org>
parents: 18631
diff changeset
1114 " It is correct that this does not pass
143d44d8f477 patch 8.2.0083: text properties wrong when tabs and spaces are exchanged
Bram Moolenaar <Bram@vim.org>
parents: 18631
diff changeset
1115 call prop_add(1, 6, {'end_col': 7, 'type': 'test'})
143d44d8f477 patch 8.2.0083: text properties wrong when tabs and spaces are exchanged
Bram Moolenaar <Bram@vim.org>
parents: 18631
diff changeset
1116 " Has already collapsed here, start_col:6 does not result in an error
143d44d8f477 patch 8.2.0083: text properties wrong when tabs and spaces are exchanged
Bram Moolenaar <Bram@vim.org>
parents: 18631
diff changeset
1117 call feedkeys("A\<left>\<tab>", "tx")
143d44d8f477 patch 8.2.0083: text properties wrong when tabs and spaces are exchanged
Bram Moolenaar <Bram@vim.org>
parents: 18631
diff changeset
1118 catch /^Vim\%((\a\+)\)\=:E964/
143d44d8f477 patch 8.2.0083: text properties wrong when tabs and spaces are exchanged
Bram Moolenaar <Bram@vim.org>
parents: 18631
diff changeset
1119 endtry
143d44d8f477 patch 8.2.0083: text properties wrong when tabs and spaces are exchanged
Bram Moolenaar <Bram@vim.org>
parents: 18631
diff changeset
1120 call prop_remove({'type': 'test'})
19097
bcbc9fe665b5 patch 8.2.0109: corrupted text properties when expanding spaces
Bram Moolenaar <Bram@vim.org>
parents: 19045
diff changeset
1121 call prop_type_delete('test')
bcbc9fe665b5 patch 8.2.0109: corrupted text properties when expanding spaces
Bram Moolenaar <Bram@vim.org>
parents: 19045
diff changeset
1122
bcbc9fe665b5 patch 8.2.0109: corrupted text properties when expanding spaces
Bram Moolenaar <Bram@vim.org>
parents: 19045
diff changeset
1123 call RestoreOptions(save_dict)
bcbc9fe665b5 patch 8.2.0109: corrupted text properties when expanding spaces
Bram Moolenaar <Bram@vim.org>
parents: 19045
diff changeset
1124 bwipe!
19045
143d44d8f477 patch 8.2.0083: text properties wrong when tabs and spaces are exchanged
Bram Moolenaar <Bram@vim.org>
parents: 18631
diff changeset
1125 endfunc
19097
bcbc9fe665b5 patch 8.2.0109: corrupted text properties when expanding spaces
Bram Moolenaar <Bram@vim.org>
parents: 19045
diff changeset
1126
bcbc9fe665b5 patch 8.2.0109: corrupted text properties when expanding spaces
Bram Moolenaar <Bram@vim.org>
parents: 19045
diff changeset
1127 func Test_textprop_noexpandtab_redraw()
bcbc9fe665b5 patch 8.2.0109: corrupted text properties when expanding spaces
Bram Moolenaar <Bram@vim.org>
parents: 19045
diff changeset
1128 new
bcbc9fe665b5 patch 8.2.0109: corrupted text properties when expanding spaces
Bram Moolenaar <Bram@vim.org>
parents: 19045
diff changeset
1129 let save_dict = SaveOptions()
bcbc9fe665b5 patch 8.2.0109: corrupted text properties when expanding spaces
Bram Moolenaar <Bram@vim.org>
parents: 19045
diff changeset
1130
bcbc9fe665b5 patch 8.2.0109: corrupted text properties when expanding spaces
Bram Moolenaar <Bram@vim.org>
parents: 19045
diff changeset
1131 set tabstop=8
bcbc9fe665b5 patch 8.2.0109: corrupted text properties when expanding spaces
Bram Moolenaar <Bram@vim.org>
parents: 19045
diff changeset
1132 set softtabstop=4
bcbc9fe665b5 patch 8.2.0109: corrupted text properties when expanding spaces
Bram Moolenaar <Bram@vim.org>
parents: 19045
diff changeset
1133 set shiftwidth=4
bcbc9fe665b5 patch 8.2.0109: corrupted text properties when expanding spaces
Bram Moolenaar <Bram@vim.org>
parents: 19045
diff changeset
1134 set noexpandtab
bcbc9fe665b5 patch 8.2.0109: corrupted text properties when expanding spaces
Bram Moolenaar <Bram@vim.org>
parents: 19045
diff changeset
1135 set foldmethod=marker
bcbc9fe665b5 patch 8.2.0109: corrupted text properties when expanding spaces
Bram Moolenaar <Bram@vim.org>
parents: 19045
diff changeset
1136
bcbc9fe665b5 patch 8.2.0109: corrupted text properties when expanding spaces
Bram Moolenaar <Bram@vim.org>
parents: 19045
diff changeset
1137 call feedkeys("\<esc>\<esc>0Ca\<cr>\<space>\<esc>\<up>", "tx")
bcbc9fe665b5 patch 8.2.0109: corrupted text properties when expanding spaces
Bram Moolenaar <Bram@vim.org>
parents: 19045
diff changeset
1138 call prop_type_add('test', {'highlight': 'ErrorMsg'})
bcbc9fe665b5 patch 8.2.0109: corrupted text properties when expanding spaces
Bram Moolenaar <Bram@vim.org>
parents: 19045
diff changeset
1139 call prop_add(1, 1, {'end_col': 2, 'type': 'test'})
bcbc9fe665b5 patch 8.2.0109: corrupted text properties when expanding spaces
Bram Moolenaar <Bram@vim.org>
parents: 19045
diff changeset
1140 call feedkeys("0i\<tab>", "tx")
bcbc9fe665b5 patch 8.2.0109: corrupted text properties when expanding spaces
Bram Moolenaar <Bram@vim.org>
parents: 19045
diff changeset
1141 " Internally broken at the next line
bcbc9fe665b5 patch 8.2.0109: corrupted text properties when expanding spaces
Bram Moolenaar <Bram@vim.org>
parents: 19045
diff changeset
1142 call feedkeys("A\<left>\<tab>", "tx")
bcbc9fe665b5 patch 8.2.0109: corrupted text properties when expanding spaces
Bram Moolenaar <Bram@vim.org>
parents: 19045
diff changeset
1143 redraw
bcbc9fe665b5 patch 8.2.0109: corrupted text properties when expanding spaces
Bram Moolenaar <Bram@vim.org>
parents: 19045
diff changeset
1144 " Index calculation failed internally on next line
bcbc9fe665b5 patch 8.2.0109: corrupted text properties when expanding spaces
Bram Moolenaar <Bram@vim.org>
parents: 19045
diff changeset
1145 call prop_add(1, 1, {'end_col': 2, 'type': 'test'})
bcbc9fe665b5 patch 8.2.0109: corrupted text properties when expanding spaces
Bram Moolenaar <Bram@vim.org>
parents: 19045
diff changeset
1146 call prop_remove({'type': 'test', 'all': v:true})
bcbc9fe665b5 patch 8.2.0109: corrupted text properties when expanding spaces
Bram Moolenaar <Bram@vim.org>
parents: 19045
diff changeset
1147 call prop_type_delete('test')
bcbc9fe665b5 patch 8.2.0109: corrupted text properties when expanding spaces
Bram Moolenaar <Bram@vim.org>
parents: 19045
diff changeset
1148 call prop_type_delete('test')
bcbc9fe665b5 patch 8.2.0109: corrupted text properties when expanding spaces
Bram Moolenaar <Bram@vim.org>
parents: 19045
diff changeset
1149
bcbc9fe665b5 patch 8.2.0109: corrupted text properties when expanding spaces
Bram Moolenaar <Bram@vim.org>
parents: 19045
diff changeset
1150 call RestoreOptions(save_dict)
bcbc9fe665b5 patch 8.2.0109: corrupted text properties when expanding spaces
Bram Moolenaar <Bram@vim.org>
parents: 19045
diff changeset
1151 bwipe!
bcbc9fe665b5 patch 8.2.0109: corrupted text properties when expanding spaces
Bram Moolenaar <Bram@vim.org>
parents: 19045
diff changeset
1152 endfunc
bcbc9fe665b5 patch 8.2.0109: corrupted text properties when expanding spaces
Bram Moolenaar <Bram@vim.org>
parents: 19045
diff changeset
1153
bcbc9fe665b5 patch 8.2.0109: corrupted text properties when expanding spaces
Bram Moolenaar <Bram@vim.org>
parents: 19045
diff changeset
1154 func Test_textprop_ins_str()
bcbc9fe665b5 patch 8.2.0109: corrupted text properties when expanding spaces
Bram Moolenaar <Bram@vim.org>
parents: 19045
diff changeset
1155 new
bcbc9fe665b5 patch 8.2.0109: corrupted text properties when expanding spaces
Bram Moolenaar <Bram@vim.org>
parents: 19045
diff changeset
1156 call setline(1, 'just some text')
bcbc9fe665b5 patch 8.2.0109: corrupted text properties when expanding spaces
Bram Moolenaar <Bram@vim.org>
parents: 19045
diff changeset
1157 call prop_type_add('test', {'highlight': 'ErrorMsg'})
bcbc9fe665b5 patch 8.2.0109: corrupted text properties when expanding spaces
Bram Moolenaar <Bram@vim.org>
parents: 19045
diff changeset
1158 call prop_add(1, 1, {'end_col': 2, 'type': 'test'})
bcbc9fe665b5 patch 8.2.0109: corrupted text properties when expanding spaces
Bram Moolenaar <Bram@vim.org>
parents: 19045
diff changeset
1159 call assert_equal([{'id': 0, 'col': 1, 'end': 1, 'type': 'test', 'length': 1, 'start': 1}], prop_list(1))
bcbc9fe665b5 patch 8.2.0109: corrupted text properties when expanding spaces
Bram Moolenaar <Bram@vim.org>
parents: 19045
diff changeset
1160
bcbc9fe665b5 patch 8.2.0109: corrupted text properties when expanding spaces
Bram Moolenaar <Bram@vim.org>
parents: 19045
diff changeset
1161 call feedkeys("foi\<F8>\<Esc>", "tx")
bcbc9fe665b5 patch 8.2.0109: corrupted text properties when expanding spaces
Bram Moolenaar <Bram@vim.org>
parents: 19045
diff changeset
1162 call assert_equal('just s<F8>ome text', getline(1))
bcbc9fe665b5 patch 8.2.0109: corrupted text properties when expanding spaces
Bram Moolenaar <Bram@vim.org>
parents: 19045
diff changeset
1163 call assert_equal([{'id': 0, 'col': 1, 'end': 1, 'type': 'test', 'length': 1, 'start': 1}], prop_list(1))
bcbc9fe665b5 patch 8.2.0109: corrupted text properties when expanding spaces
Bram Moolenaar <Bram@vim.org>
parents: 19045
diff changeset
1164
bcbc9fe665b5 patch 8.2.0109: corrupted text properties when expanding spaces
Bram Moolenaar <Bram@vim.org>
parents: 19045
diff changeset
1165 bwipe!
bcbc9fe665b5 patch 8.2.0109: corrupted text properties when expanding spaces
Bram Moolenaar <Bram@vim.org>
parents: 19045
diff changeset
1166 call prop_remove({'type': 'test'})
bcbc9fe665b5 patch 8.2.0109: corrupted text properties when expanding spaces
Bram Moolenaar <Bram@vim.org>
parents: 19045
diff changeset
1167 call prop_type_delete('test')
bcbc9fe665b5 patch 8.2.0109: corrupted text properties when expanding spaces
Bram Moolenaar <Bram@vim.org>
parents: 19045
diff changeset
1168 endfunc
19631
1d493fce1fbd patch 8.2.0372: prop_find() may not find text property at start of the line
Bram Moolenaar <Bram@vim.org>
parents: 19601
diff changeset
1169
1d493fce1fbd patch 8.2.0372: prop_find() may not find text property at start of the line
Bram Moolenaar <Bram@vim.org>
parents: 19601
diff changeset
1170 func Test_find_prop_later_in_line()
1d493fce1fbd patch 8.2.0372: prop_find() may not find text property at start of the line
Bram Moolenaar <Bram@vim.org>
parents: 19601
diff changeset
1171 new
1d493fce1fbd patch 8.2.0372: prop_find() may not find text property at start of the line
Bram Moolenaar <Bram@vim.org>
parents: 19601
diff changeset
1172 call prop_type_add('test', {'highlight': 'ErrorMsg'})
1d493fce1fbd patch 8.2.0372: prop_find() may not find text property at start of the line
Bram Moolenaar <Bram@vim.org>
parents: 19601
diff changeset
1173 call setline(1, 'just some text')
1d493fce1fbd patch 8.2.0372: prop_find() may not find text property at start of the line
Bram Moolenaar <Bram@vim.org>
parents: 19601
diff changeset
1174 call prop_add(1, 1, {'length': 4, 'type': 'test'})
1d493fce1fbd patch 8.2.0372: prop_find() may not find text property at start of the line
Bram Moolenaar <Bram@vim.org>
parents: 19601
diff changeset
1175 call prop_add(1, 10, {'length': 3, 'type': 'test'})
1d493fce1fbd patch 8.2.0372: prop_find() may not find text property at start of the line
Bram Moolenaar <Bram@vim.org>
parents: 19601
diff changeset
1176
1d493fce1fbd patch 8.2.0372: prop_find() may not find text property at start of the line
Bram Moolenaar <Bram@vim.org>
parents: 19601
diff changeset
1177 call assert_equal({'id': 0, 'lnum': 1, 'col': 10, 'end': 1, 'type': 'test', 'length': 3, 'start': 1},
1d493fce1fbd patch 8.2.0372: prop_find() may not find text property at start of the line
Bram Moolenaar <Bram@vim.org>
parents: 19601
diff changeset
1178 \ prop_find(#{type: 'test', lnum: 1, col: 6}))
1d493fce1fbd patch 8.2.0372: prop_find() may not find text property at start of the line
Bram Moolenaar <Bram@vim.org>
parents: 19601
diff changeset
1179
1d493fce1fbd patch 8.2.0372: prop_find() may not find text property at start of the line
Bram Moolenaar <Bram@vim.org>
parents: 19601
diff changeset
1180 bwipe!
1d493fce1fbd patch 8.2.0372: prop_find() may not find text property at start of the line
Bram Moolenaar <Bram@vim.org>
parents: 19601
diff changeset
1181 call prop_type_delete('test')
1d493fce1fbd patch 8.2.0372: prop_find() may not find text property at start of the line
Bram Moolenaar <Bram@vim.org>
parents: 19601
diff changeset
1182 endfunc
1d493fce1fbd patch 8.2.0372: prop_find() may not find text property at start of the line
Bram Moolenaar <Bram@vim.org>
parents: 19601
diff changeset
1183
1d493fce1fbd patch 8.2.0372: prop_find() may not find text property at start of the line
Bram Moolenaar <Bram@vim.org>
parents: 19601
diff changeset
1184 func Test_find_zerowidth_prop_sol()
1d493fce1fbd patch 8.2.0372: prop_find() may not find text property at start of the line
Bram Moolenaar <Bram@vim.org>
parents: 19601
diff changeset
1185 new
1d493fce1fbd patch 8.2.0372: prop_find() may not find text property at start of the line
Bram Moolenaar <Bram@vim.org>
parents: 19601
diff changeset
1186 call prop_type_add('test', {'highlight': 'ErrorMsg'})
1d493fce1fbd patch 8.2.0372: prop_find() may not find text property at start of the line
Bram Moolenaar <Bram@vim.org>
parents: 19601
diff changeset
1187 call setline(1, 'just some text')
1d493fce1fbd patch 8.2.0372: prop_find() may not find text property at start of the line
Bram Moolenaar <Bram@vim.org>
parents: 19601
diff changeset
1188 call prop_add(1, 1, {'length': 0, 'type': 'test'})
1d493fce1fbd patch 8.2.0372: prop_find() may not find text property at start of the line
Bram Moolenaar <Bram@vim.org>
parents: 19601
diff changeset
1189
1d493fce1fbd patch 8.2.0372: prop_find() may not find text property at start of the line
Bram Moolenaar <Bram@vim.org>
parents: 19601
diff changeset
1190 call assert_equal({'id': 0, 'lnum': 1, 'col': 1, 'end': 1, 'type': 'test', 'length': 0, 'start': 1},
1d493fce1fbd patch 8.2.0372: prop_find() may not find text property at start of the line
Bram Moolenaar <Bram@vim.org>
parents: 19601
diff changeset
1191 \ prop_find(#{type: 'test', lnum: 1}))
1d493fce1fbd patch 8.2.0372: prop_find() may not find text property at start of the line
Bram Moolenaar <Bram@vim.org>
parents: 19601
diff changeset
1192
1d493fce1fbd patch 8.2.0372: prop_find() may not find text property at start of the line
Bram Moolenaar <Bram@vim.org>
parents: 19601
diff changeset
1193 bwipe!
1d493fce1fbd patch 8.2.0372: prop_find() may not find text property at start of the line
Bram Moolenaar <Bram@vim.org>
parents: 19601
diff changeset
1194 call prop_type_delete('test')
1d493fce1fbd patch 8.2.0372: prop_find() may not find text property at start of the line
Bram Moolenaar <Bram@vim.org>
parents: 19601
diff changeset
1195 endfunc