annotate src/testdir/test_textprop.vim @ 29583:32aee589fc9a v9.0.0132

patch 9.0.0132: multi-byte characters in virtual text not handled correctly Commit: https://github.com/vim/vim/commit/09ff4b54fb86a64390ba9c609853c6410ea6197c Author: Bram Moolenaar <Bram@vim.org> Date: Mon Aug 1 16:51:02 2022 +0100 patch 9.0.0132: multi-byte characters in virtual text not handled correctly Problem: Multi-byte characters in virtual text not handled correctly. Solution: Count screen cells instead of bytes.
author Bram Moolenaar <Bram@vim.org>
date Mon, 01 Aug 2022 18:00:05 +0200
parents 4a79bca8a76e
children e357bc89bb95
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
27457
4c16acb2525f patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 26384
diff changeset
8 import './vim9.vim' as v9
15314
c4d62945d96f patch 8.1.0665: text property display wrong when 'spell' is set
Bram Moolenaar <Bram@vim.org>
parents: 15294
diff changeset
9
15138
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
10 func Test_proptype_global()
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
11 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
12 let proptypes = prop_type_list()
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
13 call assert_equal(1, len(proptypes))
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
14 call assert_equal('comment', proptypes[0])
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
15
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
16 let proptype = prop_type_get('comment')
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
17 call assert_equal('Directory', proptype['highlight'])
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
18 call assert_equal(123, proptype['priority'])
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
19 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
20 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
21
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
22 call prop_type_delete('comment')
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
23 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
24
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
25 call prop_type_add('one', {})
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
26 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
27 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
28 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
29 call assert_equal(0, proptype['priority'])
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
30 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
31 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
32
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
33 call prop_type_add('two', {})
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
34 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
35 call prop_type_delete('one')
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
36 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
37 call prop_type_delete('two')
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
38 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
39 endfunc
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
40
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
41 func Test_proptype_buf()
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
42 let bufnr = bufnr('')
25392
b427a26b0210 patch 8.2.3233: prop_list() and prop_find() do not indicate the buffer
Bram Moolenaar <Bram@vim.org>
parents: 25198
diff changeset
43 call prop_type_add('comment', #{bufnr: bufnr, highlight: 'Directory', priority: 123, start_incl: 1, end_incl: 1})
15138
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
44 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
45 call assert_equal(1, len(proptypes))
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
46 call assert_equal('comment', proptypes[0])
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
47
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
48 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
49 call assert_equal('Directory', proptype['highlight'])
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
50 call assert_equal(123, proptype['priority'])
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
51 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
52 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
53
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
54 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
55 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
56
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
57 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
58 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
59 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
60 call assert_equal(0, proptype['priority'])
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
61 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
62 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
63
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
64 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
65 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
66 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
67 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
68 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
69 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
70
18093a6accb5 patch 8.1.1388: errors when calling prop_remove() for an unloaded buffer
Bram Moolenaar <Bram@vim.org>
parents: 16770
diff changeset
71 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
72 endfunc
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
73
25392
b427a26b0210 patch 8.2.3233: prop_list() and prop_find() do not indicate the buffer
Bram Moolenaar <Bram@vim.org>
parents: 25198
diff changeset
74 def Test_proptype_buf_list()
b427a26b0210 patch 8.2.3233: prop_list() and prop_find() do not indicate the buffer
Bram Moolenaar <Bram@vim.org>
parents: 25198
diff changeset
75 new
b427a26b0210 patch 8.2.3233: prop_list() and prop_find() do not indicate the buffer
Bram Moolenaar <Bram@vim.org>
parents: 25198
diff changeset
76 var bufnr = bufnr('')
b427a26b0210 patch 8.2.3233: prop_list() and prop_find() do not indicate the buffer
Bram Moolenaar <Bram@vim.org>
parents: 25198
diff changeset
77 try
b427a26b0210 patch 8.2.3233: prop_list() and prop_find() do not indicate the buffer
Bram Moolenaar <Bram@vim.org>
parents: 25198
diff changeset
78 prop_type_add('global', {})
b427a26b0210 patch 8.2.3233: prop_list() and prop_find() do not indicate the buffer
Bram Moolenaar <Bram@vim.org>
parents: 25198
diff changeset
79 prop_type_add('local', {bufnr: bufnr})
b427a26b0210 patch 8.2.3233: prop_list() and prop_find() do not indicate the buffer
Bram Moolenaar <Bram@vim.org>
parents: 25198
diff changeset
80
b427a26b0210 patch 8.2.3233: prop_list() and prop_find() do not indicate the buffer
Bram Moolenaar <Bram@vim.org>
parents: 25198
diff changeset
81 prop_add(1, 1, {type: 'global'})
b427a26b0210 patch 8.2.3233: prop_list() and prop_find() do not indicate the buffer
Bram Moolenaar <Bram@vim.org>
parents: 25198
diff changeset
82 prop_add(1, 1, {type: 'local'})
b427a26b0210 patch 8.2.3233: prop_list() and prop_find() do not indicate the buffer
Bram Moolenaar <Bram@vim.org>
parents: 25198
diff changeset
83
b427a26b0210 patch 8.2.3233: prop_list() and prop_find() do not indicate the buffer
Bram Moolenaar <Bram@vim.org>
parents: 25198
diff changeset
84 assert_equal([
b427a26b0210 patch 8.2.3233: prop_list() and prop_find() do not indicate the buffer
Bram Moolenaar <Bram@vim.org>
parents: 25198
diff changeset
85 {type: 'local', type_bufnr: bufnr, id: 0, col: 1, end: 1, length: 0, start: 1},
b427a26b0210 patch 8.2.3233: prop_list() and prop_find() do not indicate the buffer
Bram Moolenaar <Bram@vim.org>
parents: 25198
diff changeset
86 {type: 'global', type_bufnr: 0, id: 0, col: 1, end: 1, length: 0, start: 1},
b427a26b0210 patch 8.2.3233: prop_list() and prop_find() do not indicate the buffer
Bram Moolenaar <Bram@vim.org>
parents: 25198
diff changeset
87 ], prop_list(1))
b427a26b0210 patch 8.2.3233: prop_list() and prop_find() do not indicate the buffer
Bram Moolenaar <Bram@vim.org>
parents: 25198
diff changeset
88 assert_equal(
b427a26b0210 patch 8.2.3233: prop_list() and prop_find() do not indicate the buffer
Bram Moolenaar <Bram@vim.org>
parents: 25198
diff changeset
89 {lnum: 1, id: 0, col: 1, type_bufnr: bufnr, end: 1, type: 'local', length: 0, start: 1},
b427a26b0210 patch 8.2.3233: prop_list() and prop_find() do not indicate the buffer
Bram Moolenaar <Bram@vim.org>
parents: 25198
diff changeset
90 prop_find({lnum: 1, type: 'local'}))
b427a26b0210 patch 8.2.3233: prop_list() and prop_find() do not indicate the buffer
Bram Moolenaar <Bram@vim.org>
parents: 25198
diff changeset
91 assert_equal(
b427a26b0210 patch 8.2.3233: prop_list() and prop_find() do not indicate the buffer
Bram Moolenaar <Bram@vim.org>
parents: 25198
diff changeset
92 {lnum: 1, id: 0, col: 1, type_bufnr: 0, end: 1, type: 'global', length: 0, start: 1},
b427a26b0210 patch 8.2.3233: prop_list() and prop_find() do not indicate the buffer
Bram Moolenaar <Bram@vim.org>
parents: 25198
diff changeset
93 prop_find({lnum: 1, type: 'global'}))
b427a26b0210 patch 8.2.3233: prop_list() and prop_find() do not indicate the buffer
Bram Moolenaar <Bram@vim.org>
parents: 25198
diff changeset
94
b427a26b0210 patch 8.2.3233: prop_list() and prop_find() do not indicate the buffer
Bram Moolenaar <Bram@vim.org>
parents: 25198
diff changeset
95 prop_remove({type: 'global'}, 1)
b427a26b0210 patch 8.2.3233: prop_list() and prop_find() do not indicate the buffer
Bram Moolenaar <Bram@vim.org>
parents: 25198
diff changeset
96 prop_remove({type: 'local'}, 1)
b427a26b0210 patch 8.2.3233: prop_list() and prop_find() do not indicate the buffer
Bram Moolenaar <Bram@vim.org>
parents: 25198
diff changeset
97 finally
b427a26b0210 patch 8.2.3233: prop_list() and prop_find() do not indicate the buffer
Bram Moolenaar <Bram@vim.org>
parents: 25198
diff changeset
98 prop_type_delete('global')
b427a26b0210 patch 8.2.3233: prop_list() and prop_find() do not indicate the buffer
Bram Moolenaar <Bram@vim.org>
parents: 25198
diff changeset
99 prop_type_delete('local', {bufnr: bufnr})
b427a26b0210 patch 8.2.3233: prop_list() and prop_find() do not indicate the buffer
Bram Moolenaar <Bram@vim.org>
parents: 25198
diff changeset
100 bwipe!
b427a26b0210 patch 8.2.3233: prop_list() and prop_find() do not indicate the buffer
Bram Moolenaar <Bram@vim.org>
parents: 25198
diff changeset
101 endtry
b427a26b0210 patch 8.2.3233: prop_list() and prop_find() do not indicate the buffer
Bram Moolenaar <Bram@vim.org>
parents: 25198
diff changeset
102 enddef
b427a26b0210 patch 8.2.3233: prop_list() and prop_find() do not indicate the buffer
Bram Moolenaar <Bram@vim.org>
parents: 25198
diff changeset
103
15138
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
104 func AddPropTypes()
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
105 call prop_type_add('one', {})
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
106 call prop_type_add('two', {})
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
107 call prop_type_add('three', {})
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
108 call prop_type_add('whole', {})
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
109 endfunc
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
110
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
111 func DeletePropTypes()
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
112 call prop_type_delete('one')
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
113 call prop_type_delete('two')
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
114 call prop_type_delete('three')
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
115 call prop_type_delete('whole')
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
116 endfunc
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
117
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
118 func SetupPropsInFirstLine()
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
119 call setline(1, 'one two three')
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
120 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
121 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
122 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
123 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
124 endfunc
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
125
15367
273649cad196 patch 8.1.0691: text properties are not adjusted for :substitute
Bram Moolenaar <Bram@vim.org>
parents: 15365
diff changeset
126 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
127 return [
25392
b427a26b0210 patch 8.2.3233: prop_list() and prop_find() do not indicate the buffer
Bram Moolenaar <Bram@vim.org>
parents: 25198
diff changeset
128 \ #{type_bufnr: 0, col: 1, length: 13, id: 14, type: 'whole', start: 1, end: 1},
b427a26b0210 patch 8.2.3233: prop_list() and prop_find() do not indicate the buffer
Bram Moolenaar <Bram@vim.org>
parents: 25198
diff changeset
129 \ #{type_bufnr: 0, col: 1, length: 3, id: 11, type: 'one', start: 1, end: 1},
b427a26b0210 patch 8.2.3233: prop_list() and prop_find() do not indicate the buffer
Bram Moolenaar <Bram@vim.org>
parents: 25198
diff changeset
130 \ #{type_bufnr: 0, col: 5, length: 3, id: 12, type: 'two', start: 1, end: 1},
b427a26b0210 patch 8.2.3233: prop_list() and prop_find() do not indicate the buffer
Bram Moolenaar <Bram@vim.org>
parents: 25198
diff changeset
131 \ #{type_bufnr: 0, 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
132 \ ]
15367
273649cad196 patch 8.1.0691: text properties are not adjusted for :substitute
Bram Moolenaar <Bram@vim.org>
parents: 15365
diff changeset
133 endfunc
15138
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
134
19100
91bb12995034 patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents: 19097
diff changeset
135 func Test_prop_find()
91bb12995034 patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents: 19097
diff changeset
136 new
91bb12995034 patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents: 19097
diff changeset
137 call setline(1, ['one one one', 'twotwo', 'three', 'fourfour', 'five', 'sixsix'])
25392
b427a26b0210 patch 8.2.3233: prop_list() and prop_find() do not indicate the buffer
Bram Moolenaar <Bram@vim.org>
parents: 25198
diff changeset
138
b427a26b0210 patch 8.2.3233: prop_list() and prop_find() do not indicate the buffer
Bram Moolenaar <Bram@vim.org>
parents: 25198
diff changeset
139 " Add two text props on lines 1 and 5, and one spanning lines 2 to 4.
19100
91bb12995034 patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents: 19097
diff changeset
140 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
141 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
142 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
143 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
144
91bb12995034 patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents: 19097
diff changeset
145 let expected = [
25392
b427a26b0210 patch 8.2.3233: prop_list() and prop_find() do not indicate the buffer
Bram Moolenaar <Bram@vim.org>
parents: 25198
diff changeset
146 \ #{type_bufnr: 0, lnum: 1, col: 5, length: 3, id: 10, type: 'prop_name', start: 1, end: 1},
b427a26b0210 patch 8.2.3233: prop_list() and prop_find() do not indicate the buffer
Bram Moolenaar <Bram@vim.org>
parents: 25198
diff changeset
147 \ #{type_bufnr: 0, lnum: 2, col: 4, id: 11, type: 'prop_name', start: 1, end: 0},
b427a26b0210 patch 8.2.3233: prop_list() and prop_find() do not indicate the buffer
Bram Moolenaar <Bram@vim.org>
parents: 25198
diff changeset
148 \ #{type_bufnr: 0, lnum: 5, col: 4, length: 1, id: 12, type: 'prop_name', start: 1, end: 1}
19100
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
91bb12995034 patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents: 19097
diff changeset
151 " 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
152 call cursor(5,1)
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'}, 'f')
91bb12995034 patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents: 19097
diff changeset
154 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
155
91bb12995034 patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents: 19097
diff changeset
156 " 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
157 " 5 col 4.
91bb12995034 patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents: 19097
diff changeset
158 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
159 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
160
91bb12995034 patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents: 19097
diff changeset
161 " 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
162 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
163 unlet result.length
91bb12995034 patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents: 19097
diff changeset
164 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
165
91bb12995034 patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents: 19097
diff changeset
166 " 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
167 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
168 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
169
91bb12995034 patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents: 19097
diff changeset
170 " 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
171 " 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
172 " 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
173 call cursor(3,1)
91bb12995034 patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents: 19097
diff changeset
174 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
175 unlet result.length
91bb12995034 patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents: 19097
diff changeset
176 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
177 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
178 unlet result.length
91bb12995034 patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents: 19097
diff changeset
179 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
180
91bb12995034 patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents: 19097
diff changeset
181 " 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
182 " 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
183 " 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
184 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
185 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
186 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
187 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
188
91bb12995034 patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents: 19097
diff changeset
189 " 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
190 " First forward...
91bb12995034 patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents: 19097
diff changeset
191 let lnum = 1
91bb12995034 patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents: 19097
diff changeset
192 let col = 1
91bb12995034 patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents: 19097
diff changeset
193 let i = 0
91bb12995034 patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents: 19097
diff changeset
194 for exp in expected
91bb12995034 patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents: 19097
diff changeset
195 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
196 if !has_key(exp, "length")
91bb12995034 patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents: 19097
diff changeset
197 unlet result.length
91bb12995034 patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents: 19097
diff changeset
198 endif
91bb12995034 patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents: 19097
diff changeset
199 call assert_equal(exp, result)
91bb12995034 patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents: 19097
diff changeset
200 let lnum = result.lnum
91bb12995034 patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents: 19097
diff changeset
201 let col = result.col
91bb12995034 patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents: 19097
diff changeset
202 let i = i + 1
91bb12995034 patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents: 19097
diff changeset
203 endfor
91bb12995034 patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents: 19097
diff changeset
204
91bb12995034 patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents: 19097
diff changeset
205 " ...then backwards.
91bb12995034 patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents: 19097
diff changeset
206 let lnum = 6
91bb12995034 patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents: 19097
diff changeset
207 let col = 4
91bb12995034 patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents: 19097
diff changeset
208 let i = 2
91bb12995034 patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents: 19097
diff changeset
209 while i >= 0
91bb12995034 patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents: 19097
diff changeset
210 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
211 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
212 unlet result.length
91bb12995034 patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents: 19097
diff changeset
213 endif
91bb12995034 patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents: 19097
diff changeset
214 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
215 let lnum = result.lnum
91bb12995034 patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents: 19097
diff changeset
216 let col = result.col
91bb12995034 patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents: 19097
diff changeset
217 let i = i - 1
25392
b427a26b0210 patch 8.2.3233: prop_list() and prop_find() do not indicate the buffer
Bram Moolenaar <Bram@vim.org>
parents: 25198
diff changeset
218 endwhile
19100
91bb12995034 patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents: 19097
diff changeset
219
91bb12995034 patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents: 19097
diff changeset
220 " 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
221 call cursor(6,1)
91bb12995034 patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents: 19097
diff changeset
222 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
223 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
224
91bb12995034 patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents: 19097
diff changeset
225 " 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
226 call cursor(1,1)
91bb12995034 patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents: 19097
diff changeset
227 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
228 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
229
91bb12995034 patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents: 19097
diff changeset
230 " 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
231 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
232 call assert_equal({}, result)
91bb12995034 patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents: 19097
diff changeset
233
91bb12995034 patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents: 19097
diff changeset
234 " 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
235 " (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
236 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
237 call assert_equal({}, result)
91bb12995034 patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents: 19097
diff changeset
238
91bb12995034 patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents: 19097
diff changeset
239 " 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
240 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
241 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
242
25471
3678a11e71fa patch 8.2.3272: cannot use id zero with prop_find()
Bram Moolenaar <Bram@vim.org>
parents: 25441
diff changeset
243 " Negative ID is possible, just like prop is not found.
25441
e06540cc3371 patch 8.2.3257: calling prop_find() with -1 for ID gives errornous error
Bram Moolenaar <Bram@vim.org>
parents: 25392
diff changeset
244 call assert_equal({}, prop_find({'id': -1}))
25471
3678a11e71fa patch 8.2.3272: cannot use id zero with prop_find()
Bram Moolenaar <Bram@vim.org>
parents: 25441
diff changeset
245 call assert_equal({}, prop_find({'id': -2}))
3678a11e71fa patch 8.2.3272: cannot use id zero with prop_find()
Bram Moolenaar <Bram@vim.org>
parents: 25441
diff changeset
246
3678a11e71fa patch 8.2.3272: cannot use id zero with prop_find()
Bram Moolenaar <Bram@vim.org>
parents: 25441
diff changeset
247 call prop_clear(1, 6)
25441
e06540cc3371 patch 8.2.3257: calling prop_find() with -1 for ID gives errornous error
Bram Moolenaar <Bram@vim.org>
parents: 25392
diff changeset
248
25471
3678a11e71fa patch 8.2.3272: cannot use id zero with prop_find()
Bram Moolenaar <Bram@vim.org>
parents: 25441
diff changeset
249 " Default ID is zero
3678a11e71fa patch 8.2.3272: cannot use id zero with prop_find()
Bram Moolenaar <Bram@vim.org>
parents: 25441
diff changeset
250 call prop_add(5, 4, {'type': 'prop_name', 'length': 1})
3678a11e71fa patch 8.2.3272: cannot use id zero with prop_find()
Bram Moolenaar <Bram@vim.org>
parents: 25441
diff changeset
251 call assert_equal(#{lnum: 5, id: 0, col: 4, type_bufnr: 0, end: 1, type: 'prop_name', length: 1, start: 1}, prop_find({'id': 0}))
3678a11e71fa patch 8.2.3272: cannot use id zero with prop_find()
Bram Moolenaar <Bram@vim.org>
parents: 25441
diff changeset
252
19100
91bb12995034 patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents: 19097
diff changeset
253 call prop_type_delete('prop_name')
25471
3678a11e71fa patch 8.2.3272: cannot use id zero with prop_find()
Bram Moolenaar <Bram@vim.org>
parents: 25441
diff changeset
254 call prop_clear(1, 6)
22069
87502e318c19 patch 8.2.1584: Vim9: cannot use "true" for "skipstart" in prop_find()
Bram Moolenaar <Bram@vim.org>
parents: 22037
diff changeset
255 bwipe!
87502e318c19 patch 8.2.1584: Vim9: cannot use "true" for "skipstart" in prop_find()
Bram Moolenaar <Bram@vim.org>
parents: 22037
diff changeset
256 endfunc
87502e318c19 patch 8.2.1584: Vim9: cannot use "true" for "skipstart" in prop_find()
Bram Moolenaar <Bram@vim.org>
parents: 22037
diff changeset
257
87502e318c19 patch 8.2.1584: Vim9: cannot use "true" for "skipstart" in prop_find()
Bram Moolenaar <Bram@vim.org>
parents: 22037
diff changeset
258 def Test_prop_find2()
87502e318c19 patch 8.2.1584: Vim9: cannot use "true" for "skipstart" in prop_find()
Bram Moolenaar <Bram@vim.org>
parents: 22037
diff changeset
259 # Multiple props per line, start on the first, should find the second.
87502e318c19 patch 8.2.1584: Vim9: cannot use "true" for "skipstart" in prop_find()
Bram Moolenaar <Bram@vim.org>
parents: 22037
diff changeset
260 new
87502e318c19 patch 8.2.1584: Vim9: cannot use "true" for "skipstart" in prop_find()
Bram Moolenaar <Bram@vim.org>
parents: 22037
diff changeset
261 ['the quikc bronw fox jumsp over the layz dog']->repeat(2)->setline(1)
23072
4b398a229b0b patch 8.2.2082: Vim9: can still use the depricated #{} dict syntax
Bram Moolenaar <Bram@vim.org>
parents: 22435
diff changeset
262 prop_type_add('misspell', {highlight: 'ErrorMsg'})
22037
35c8996a798e patch 8.2.1568: prop_find() skips properties in the same line
Bram Moolenaar <Bram@vim.org>
parents: 21552
diff changeset
263 for lnum in [1, 2]
35c8996a798e patch 8.2.1568: prop_find() skips properties in the same line
Bram Moolenaar <Bram@vim.org>
parents: 21552
diff changeset
264 for col in [8, 14, 24, 38]
23072
4b398a229b0b patch 8.2.2082: Vim9: can still use the depricated #{} dict syntax
Bram Moolenaar <Bram@vim.org>
parents: 22435
diff changeset
265 prop_add(lnum, col, {type: 'misspell', length: 2})
22037
35c8996a798e patch 8.2.1568: prop_find() skips properties in the same line
Bram Moolenaar <Bram@vim.org>
parents: 21552
diff changeset
266 endfor
35c8996a798e patch 8.2.1568: prop_find() skips properties in the same line
Bram Moolenaar <Bram@vim.org>
parents: 21552
diff changeset
267 endfor
22069
87502e318c19 patch 8.2.1584: Vim9: cannot use "true" for "skipstart" in prop_find()
Bram Moolenaar <Bram@vim.org>
parents: 22037
diff changeset
268 cursor(1, 8)
25392
b427a26b0210 patch 8.2.3233: prop_list() and prop_find() do not indicate the buffer
Bram Moolenaar <Bram@vim.org>
parents: 25198
diff changeset
269 var expected = {type_bufnr: 0, lnum: 1, id: 0, col: 14, end: 1, type: 'misspell', length: 2, start: 1}
23072
4b398a229b0b patch 8.2.2082: Vim9: can still use the depricated #{} dict syntax
Bram Moolenaar <Bram@vim.org>
parents: 22435
diff changeset
270 var result = prop_find({type: 'misspell', skipstart: true}, 'f')
22069
87502e318c19 patch 8.2.1584: Vim9: cannot use "true" for "skipstart" in prop_find()
Bram Moolenaar <Bram@vim.org>
parents: 22037
diff changeset
271 assert_equal(expected, result)
22037
35c8996a798e patch 8.2.1568: prop_find() skips properties in the same line
Bram Moolenaar <Bram@vim.org>
parents: 21552
diff changeset
272
22069
87502e318c19 patch 8.2.1584: Vim9: cannot use "true" for "skipstart" in prop_find()
Bram Moolenaar <Bram@vim.org>
parents: 22037
diff changeset
273 prop_type_delete('misspell')
22037
35c8996a798e patch 8.2.1568: prop_find() skips properties in the same line
Bram Moolenaar <Bram@vim.org>
parents: 21552
diff changeset
274 bwipe!
22069
87502e318c19 patch 8.2.1584: Vim9: cannot use "true" for "skipstart" in prop_find()
Bram Moolenaar <Bram@vim.org>
parents: 22037
diff changeset
275 enddef
19100
91bb12995034 patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents: 19097
diff changeset
276
19642
647ef636a11e patch 8.2.0378: prop_find() does not find all props
Bram Moolenaar <Bram@vim.org>
parents: 19631
diff changeset
277 func Test_prop_find_smaller_len_than_match_col()
647ef636a11e patch 8.2.0378: prop_find() does not find all props
Bram Moolenaar <Bram@vim.org>
parents: 19631
diff changeset
278 new
647ef636a11e patch 8.2.0378: prop_find() does not find all props
Bram Moolenaar <Bram@vim.org>
parents: 19631
diff changeset
279 call prop_type_add('test', {'highlight': 'ErrorMsg'})
647ef636a11e patch 8.2.0378: prop_find() does not find all props
Bram Moolenaar <Bram@vim.org>
parents: 19631
diff changeset
280 call setline(1, ['xxxx', 'x'])
647ef636a11e patch 8.2.0378: prop_find() does not find all props
Bram Moolenaar <Bram@vim.org>
parents: 19631
diff changeset
281 call prop_add(1, 4, {'type': 'test'})
25392
b427a26b0210 patch 8.2.3233: prop_list() and prop_find() do not indicate the buffer
Bram Moolenaar <Bram@vim.org>
parents: 25198
diff changeset
282 call assert_equal(
b427a26b0210 patch 8.2.3233: prop_list() and prop_find() do not indicate the buffer
Bram Moolenaar <Bram@vim.org>
parents: 25198
diff changeset
283 \ #{type_bufnr: 0, id: 0, lnum: 1, col: 4, type: 'test', length: 0, start: 1, end: 1},
19642
647ef636a11e patch 8.2.0378: prop_find() does not find all props
Bram Moolenaar <Bram@vim.org>
parents: 19631
diff changeset
284 \ prop_find({'type': 'test', 'lnum': 2, 'col': 1}, 'b'))
647ef636a11e patch 8.2.0378: prop_find() does not find all props
Bram Moolenaar <Bram@vim.org>
parents: 19631
diff changeset
285 bwipe!
647ef636a11e patch 8.2.0378: prop_find() does not find all props
Bram Moolenaar <Bram@vim.org>
parents: 19631
diff changeset
286 call prop_type_delete('test')
647ef636a11e patch 8.2.0378: prop_find() does not find all props
Bram Moolenaar <Bram@vim.org>
parents: 19631
diff changeset
287 endfunc
647ef636a11e patch 8.2.0378: prop_find() does not find all props
Bram Moolenaar <Bram@vim.org>
parents: 19631
diff changeset
288
24252
7422f2f719a3 patch 8.2.2667: prop_find() cannot find item matching both id and type
Bram Moolenaar <Bram@vim.org>
parents: 24039
diff changeset
289 func Test_prop_find_with_both_option_enabled()
7422f2f719a3 patch 8.2.2667: prop_find() cannot find item matching both id and type
Bram Moolenaar <Bram@vim.org>
parents: 24039
diff changeset
290 " Initialize
7422f2f719a3 patch 8.2.2667: prop_find() cannot find item matching both id and type
Bram Moolenaar <Bram@vim.org>
parents: 24039
diff changeset
291 new
7422f2f719a3 patch 8.2.2667: prop_find() cannot find item matching both id and type
Bram Moolenaar <Bram@vim.org>
parents: 24039
diff changeset
292 call AddPropTypes()
7422f2f719a3 patch 8.2.2667: prop_find() cannot find item matching both id and type
Bram Moolenaar <Bram@vim.org>
parents: 24039
diff changeset
293 call SetupPropsInFirstLine()
7422f2f719a3 patch 8.2.2667: prop_find() cannot find item matching both id and type
Bram Moolenaar <Bram@vim.org>
parents: 24039
diff changeset
294 let props = Get_expected_props()->map({_, v -> extend(v, {'lnum': 1})})
7422f2f719a3 patch 8.2.2667: prop_find() cannot find item matching both id and type
Bram Moolenaar <Bram@vim.org>
parents: 24039
diff changeset
295 " Test
7422f2f719a3 patch 8.2.2667: prop_find() cannot find item matching both id and type
Bram Moolenaar <Bram@vim.org>
parents: 24039
diff changeset
296 call assert_fails("call prop_find({'both': 1})", 'E968:')
7422f2f719a3 patch 8.2.2667: prop_find() cannot find item matching both id and type
Bram Moolenaar <Bram@vim.org>
parents: 24039
diff changeset
297 call assert_fails("call prop_find({'id': 11, 'both': 1})", 'E860:')
7422f2f719a3 patch 8.2.2667: prop_find() cannot find item matching both id and type
Bram Moolenaar <Bram@vim.org>
parents: 24039
diff changeset
298 call assert_fails("call prop_find({'type': 'three', 'both': 1})", 'E860:')
7422f2f719a3 patch 8.2.2667: prop_find() cannot find item matching both id and type
Bram Moolenaar <Bram@vim.org>
parents: 24039
diff changeset
299 call assert_equal({}, prop_find({'id': 11, 'type': 'three', 'both': 1}))
7422f2f719a3 patch 8.2.2667: prop_find() cannot find item matching both id and type
Bram Moolenaar <Bram@vim.org>
parents: 24039
diff changeset
300 call assert_equal({}, prop_find({'id': 130000, 'type': 'one', 'both': 1}))
7422f2f719a3 patch 8.2.2667: prop_find() cannot find item matching both id and type
Bram Moolenaar <Bram@vim.org>
parents: 24039
diff changeset
301 call assert_equal(props[2], prop_find({'id': 12, 'type': 'two', 'both': 1}))
7422f2f719a3 patch 8.2.2667: prop_find() cannot find item matching both id and type
Bram Moolenaar <Bram@vim.org>
parents: 24039
diff changeset
302 call assert_equal(props[0], prop_find({'id': 14, 'type': 'whole', 'both': 1}))
7422f2f719a3 patch 8.2.2667: prop_find() cannot find item matching both id and type
Bram Moolenaar <Bram@vim.org>
parents: 24039
diff changeset
303 " Clean up
7422f2f719a3 patch 8.2.2667: prop_find() cannot find item matching both id and type
Bram Moolenaar <Bram@vim.org>
parents: 24039
diff changeset
304 call DeletePropTypes()
7422f2f719a3 patch 8.2.2667: prop_find() cannot find item matching both id and type
Bram Moolenaar <Bram@vim.org>
parents: 24039
diff changeset
305 bwipe!
7422f2f719a3 patch 8.2.2667: prop_find() cannot find item matching both id and type
Bram Moolenaar <Bram@vim.org>
parents: 24039
diff changeset
306 endfunc
7422f2f719a3 patch 8.2.2667: prop_find() cannot find item matching both id and type
Bram Moolenaar <Bram@vim.org>
parents: 24039
diff changeset
307
15138
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
308 func Test_prop_add()
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
309 new
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
310 call AddPropTypes()
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
311 call SetupPropsInFirstLine()
15367
273649cad196 patch 8.1.0691: text properties are not adjusted for :substitute
Bram Moolenaar <Bram@vim.org>
parents: 15365
diff changeset
312 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
313 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
314 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
315 call assert_fails("call prop_add(1, 22, {'length': 1, 'id': 14, 'type': 'whole'})", 'E964:')
25392
b427a26b0210 patch 8.2.3233: prop_list() and prop_find() do not indicate the buffer
Bram Moolenaar <Bram@vim.org>
parents: 25198
diff changeset
316
15138
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
317 " 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
318 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
319 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
320 " 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
321 1del
15367
273649cad196 patch 8.1.0691: text properties are not adjusted for :substitute
Bram Moolenaar <Bram@vim.org>
parents: 15365
diff changeset
322 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
323
15335
18c20ceee4b5 patch 8.1.0675: text property column in screen columns is not practical
Bram Moolenaar <Bram@vim.org>
parents: 15318
diff changeset
324 " 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
325 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
326 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
327 call prop_add(1, 5, #{type: 'included'})
25392
b427a26b0210 patch 8.2.3233: prop_list() and prop_find() do not indicate the buffer
Bram Moolenaar <Bram@vim.org>
parents: 25198
diff changeset
328 let expected = [#{type_bufnr: 0, col: 5, length: 0, type: 'included', id: 0, start: 1, end: 1}]
19534
36ec10251b2b patch 8.2.0324: text property not updated correctly when inserting/deleting
Bram Moolenaar <Bram@vim.org>
parents: 19110
diff changeset
329 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
330
36ec10251b2b patch 8.2.0324: text property not updated correctly when inserting/deleting
Bram Moolenaar <Bram@vim.org>
parents: 19110
diff changeset
331 " 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
332 exe "normal 5|ixx\<Esc>"
25392
b427a26b0210 patch 8.2.3233: prop_list() and prop_find() do not indicate the buffer
Bram Moolenaar <Bram@vim.org>
parents: 25198
diff changeset
333 let expected = [#{type_bufnr: 0, 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
334 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
335
16772
18093a6accb5 patch 8.1.1388: errors when calling prop_remove() for an unloaded buffer
Bram Moolenaar <Bram@vim.org>
parents: 16770
diff changeset
336 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
337
15138
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
338 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
339 call prop_type_delete('included')
15138
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
340 bwipe!
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
341 endfunc
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
342
25640
78ef12e0ce8c patch 8.2.3356: adding many text properties requires a lot of function calls
Bram Moolenaar <Bram@vim.org>
parents: 25628
diff changeset
343 " Test for the prop_add_list() function
78ef12e0ce8c patch 8.2.3356: adding many text properties requires a lot of function calls
Bram Moolenaar <Bram@vim.org>
parents: 25628
diff changeset
344 func Test_prop_add_list()
78ef12e0ce8c patch 8.2.3356: adding many text properties requires a lot of function calls
Bram Moolenaar <Bram@vim.org>
parents: 25628
diff changeset
345 new
78ef12e0ce8c patch 8.2.3356: adding many text properties requires a lot of function calls
Bram Moolenaar <Bram@vim.org>
parents: 25628
diff changeset
346 call AddPropTypes()
78ef12e0ce8c patch 8.2.3356: adding many text properties requires a lot of function calls
Bram Moolenaar <Bram@vim.org>
parents: 25628
diff changeset
347 call setline(1, ['one one one', 'two two two', 'six six six', 'ten ten ten'])
78ef12e0ce8c patch 8.2.3356: adding many text properties requires a lot of function calls
Bram Moolenaar <Bram@vim.org>
parents: 25628
diff changeset
348 call prop_add_list(#{type: 'one', id: 2},
78ef12e0ce8c patch 8.2.3356: adding many text properties requires a lot of function calls
Bram Moolenaar <Bram@vim.org>
parents: 25628
diff changeset
349 \ [[1, 1, 1, 3], [2, 5, 2, 7], [3, 6, 4, 6]])
78ef12e0ce8c patch 8.2.3356: adding many text properties requires a lot of function calls
Bram Moolenaar <Bram@vim.org>
parents: 25628
diff changeset
350 call assert_equal([#{id: 2, col: 1, type_bufnr: 0, end: 1, type: 'one',
78ef12e0ce8c patch 8.2.3356: adding many text properties requires a lot of function calls
Bram Moolenaar <Bram@vim.org>
parents: 25628
diff changeset
351 \ length: 2, start: 1}], prop_list(1))
78ef12e0ce8c patch 8.2.3356: adding many text properties requires a lot of function calls
Bram Moolenaar <Bram@vim.org>
parents: 25628
diff changeset
352 call assert_equal([#{id: 2, col: 5, type_bufnr: 0, end: 1, type: 'one',
78ef12e0ce8c patch 8.2.3356: adding many text properties requires a lot of function calls
Bram Moolenaar <Bram@vim.org>
parents: 25628
diff changeset
353 \ length: 2, start: 1}], prop_list(2))
78ef12e0ce8c patch 8.2.3356: adding many text properties requires a lot of function calls
Bram Moolenaar <Bram@vim.org>
parents: 25628
diff changeset
354 call assert_equal([#{id: 2, col: 6, type_bufnr: 0, end: 0, type: 'one',
78ef12e0ce8c patch 8.2.3356: adding many text properties requires a lot of function calls
Bram Moolenaar <Bram@vim.org>
parents: 25628
diff changeset
355 \ length: 7, start: 1}], prop_list(3))
78ef12e0ce8c patch 8.2.3356: adding many text properties requires a lot of function calls
Bram Moolenaar <Bram@vim.org>
parents: 25628
diff changeset
356 call assert_equal([#{id: 2, col: 1, type_bufnr: 0, end: 1, type: 'one',
78ef12e0ce8c patch 8.2.3356: adding many text properties requires a lot of function calls
Bram Moolenaar <Bram@vim.org>
parents: 25628
diff changeset
357 \ length: 5, start: 0}], prop_list(4))
78ef12e0ce8c patch 8.2.3356: adding many text properties requires a lot of function calls
Bram Moolenaar <Bram@vim.org>
parents: 25628
diff changeset
358 call assert_fails('call prop_add_list([1, 2], [[1, 1, 3]])', 'E1206:')
78ef12e0ce8c patch 8.2.3356: adding many text properties requires a lot of function calls
Bram Moolenaar <Bram@vim.org>
parents: 25628
diff changeset
359 call assert_fails('call prop_add_list({}, {})', 'E1211:')
78ef12e0ce8c patch 8.2.3356: adding many text properties requires a lot of function calls
Bram Moolenaar <Bram@vim.org>
parents: 25628
diff changeset
360 call assert_fails('call prop_add_list({}, [[1, 1, 3]])', 'E965:')
78ef12e0ce8c patch 8.2.3356: adding many text properties requires a lot of function calls
Bram Moolenaar <Bram@vim.org>
parents: 25628
diff changeset
361 call assert_fails('call prop_add_list(#{type: "abc"}, [[1, 1, 1, 3]])', 'E971:')
78ef12e0ce8c patch 8.2.3356: adding many text properties requires a lot of function calls
Bram Moolenaar <Bram@vim.org>
parents: 25628
diff changeset
362 call assert_fails('call prop_add_list(#{type: "one"}, [[]])', 'E474:')
78ef12e0ce8c patch 8.2.3356: adding many text properties requires a lot of function calls
Bram Moolenaar <Bram@vim.org>
parents: 25628
diff changeset
363 call assert_fails('call prop_add_list(#{type: "one"}, [[1, 1, 1, 1], {}])', 'E714:')
78ef12e0ce8c patch 8.2.3356: adding many text properties requires a lot of function calls
Bram Moolenaar <Bram@vim.org>
parents: 25628
diff changeset
364 call assert_fails('call prop_add_list(#{type: "one"}, [[1, 1, "a"]])', 'E474:')
78ef12e0ce8c patch 8.2.3356: adding many text properties requires a lot of function calls
Bram Moolenaar <Bram@vim.org>
parents: 25628
diff changeset
365 call assert_fails('call prop_add_list(#{type: "one"}, [[2, 2]])', 'E474:')
78ef12e0ce8c patch 8.2.3356: adding many text properties requires a lot of function calls
Bram Moolenaar <Bram@vim.org>
parents: 25628
diff changeset
366 call assert_fails('call prop_add_list(#{type: "one"}, [[1, 1, 2], [2, 2]])', 'E474:')
78ef12e0ce8c patch 8.2.3356: adding many text properties requires a lot of function calls
Bram Moolenaar <Bram@vim.org>
parents: 25628
diff changeset
367 call assert_fails('call prop_add_list(#{type: "one"}, [[1, 1, 1, 2], [4, 1, 5, 2]])', 'E966:')
78ef12e0ce8c patch 8.2.3356: adding many text properties requires a lot of function calls
Bram Moolenaar <Bram@vim.org>
parents: 25628
diff changeset
368 call assert_fails('call prop_add_list(#{type: "one"}, [[3, 1, 1, 2]])', 'E966:')
78ef12e0ce8c patch 8.2.3356: adding many text properties requires a lot of function calls
Bram Moolenaar <Bram@vim.org>
parents: 25628
diff changeset
369 call assert_fails('call prop_add_list(#{type: "one"}, [[2, 2, 2, 2], [3, 20, 3, 22]])', 'E964:')
78ef12e0ce8c patch 8.2.3356: adding many text properties requires a lot of function calls
Bram Moolenaar <Bram@vim.org>
parents: 25628
diff changeset
370 call assert_fails('eval #{type: "one"}->prop_add_list([[2, 2, 2, 2], [3, 20, 3, 22]])', 'E964:')
78ef12e0ce8c patch 8.2.3356: adding many text properties requires a lot of function calls
Bram Moolenaar <Bram@vim.org>
parents: 25628
diff changeset
371 call assert_fails('call prop_add_list(test_null_dict(), [[2, 2, 2]])', 'E965:')
78ef12e0ce8c patch 8.2.3356: adding many text properties requires a lot of function calls
Bram Moolenaar <Bram@vim.org>
parents: 25628
diff changeset
372 call assert_fails('call prop_add_list(#{type: "one"}, test_null_list())', 'E714:')
78ef12e0ce8c patch 8.2.3356: adding many text properties requires a lot of function calls
Bram Moolenaar <Bram@vim.org>
parents: 25628
diff changeset
373 call assert_fails('call prop_add_list(#{type: "one"}, [test_null_list()])', 'E714:')
78ef12e0ce8c patch 8.2.3356: adding many text properties requires a lot of function calls
Bram Moolenaar <Bram@vim.org>
parents: 25628
diff changeset
374 call DeletePropTypes()
78ef12e0ce8c patch 8.2.3356: adding many text properties requires a lot of function calls
Bram Moolenaar <Bram@vim.org>
parents: 25628
diff changeset
375 bw!
78ef12e0ce8c patch 8.2.3356: adding many text properties requires a lot of function calls
Bram Moolenaar <Bram@vim.org>
parents: 25628
diff changeset
376 endfunc
78ef12e0ce8c patch 8.2.3356: adding many text properties requires a lot of function calls
Bram Moolenaar <Bram@vim.org>
parents: 25628
diff changeset
377
15138
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
378 func Test_prop_remove()
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
379 new
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
380 call AddPropTypes()
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
381 call SetupPropsInFirstLine()
15367
273649cad196 patch 8.1.0691: text properties are not adjusted for :substitute
Bram Moolenaar <Bram@vim.org>
parents: 15365
diff changeset
382 let props = Get_expected_props()
15138
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
383 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
384
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
385 " 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
386 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
387 unlet props[2]
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
388 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
389
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
390 " 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
391 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
392 unlet props[1]
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
393 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
394
16772
18093a6accb5 patch 8.1.1388: errors when calling prop_remove() for an unloaded buffer
Bram Moolenaar <Bram@vim.org>
parents: 16770
diff changeset
395 " 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
396 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
397
15138
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
398 call DeletePropTypes()
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
399 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
400
67f39cb0a49c patch 8.2.0357: cannot delete a text property matching both id and type
Bram Moolenaar <Bram@vim.org>
parents: 19534
diff changeset
401 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
402 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
403 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
404 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
405 let props = Get_expected_props()
25392
b427a26b0210 patch 8.2.3233: prop_list() and prop_find() do not indicate the buffer
Bram Moolenaar <Bram@vim.org>
parents: 25198
diff changeset
406 call insert(props, #{type_bufnr: 0, col: 6, length: 2, id: 11, type: 'three', start: 1, end: 1}, 3)
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
407 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
408 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
409 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
410 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
411
22087
ff21e2962490 patch 8.2.1593: tests do not check the error number properly
Bram Moolenaar <Bram@vim.org>
parents: 22069
diff changeset
412 call assert_fails("call prop_remove({'id': 11, 'both': 1})", 'E860:')
ff21e2962490 patch 8.2.1593: tests do not check the error number properly
Bram Moolenaar <Bram@vim.org>
parents: 22069
diff changeset
413 call assert_fails("call prop_remove({'type': 'three', 'both': 1})", 'E860:')
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
414
67f39cb0a49c patch 8.2.0357: cannot delete a text property matching both id and type
Bram Moolenaar <Bram@vim.org>
parents: 19534
diff changeset
415 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
416 bwipe!
15138
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
417 endfunc
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
418
22127
9d3dfd420a45 patch 8.2.1613: Vim9: cannot pass "true" to prop_type_add()
Bram Moolenaar <Bram@vim.org>
parents: 22125
diff changeset
419 def Test_prop_add_vim9()
23072
4b398a229b0b patch 8.2.2082: Vim9: can still use the depricated #{} dict syntax
Bram Moolenaar <Bram@vim.org>
parents: 22435
diff changeset
420 prop_type_add('comment', {
22127
9d3dfd420a45 patch 8.2.1613: Vim9: cannot pass "true" to prop_type_add()
Bram Moolenaar <Bram@vim.org>
parents: 22125
diff changeset
421 highlight: 'Directory',
9d3dfd420a45 patch 8.2.1613: Vim9: cannot pass "true" to prop_type_add()
Bram Moolenaar <Bram@vim.org>
parents: 22125
diff changeset
422 priority: 123,
9d3dfd420a45 patch 8.2.1613: Vim9: cannot pass "true" to prop_type_add()
Bram Moolenaar <Bram@vim.org>
parents: 22125
diff changeset
423 start_incl: true,
9d3dfd420a45 patch 8.2.1613: Vim9: cannot pass "true" to prop_type_add()
Bram Moolenaar <Bram@vim.org>
parents: 22125
diff changeset
424 end_incl: true,
9d3dfd420a45 patch 8.2.1613: Vim9: cannot pass "true" to prop_type_add()
Bram Moolenaar <Bram@vim.org>
parents: 22125
diff changeset
425 combine: false,
9d3dfd420a45 patch 8.2.1613: Vim9: cannot pass "true" to prop_type_add()
Bram Moolenaar <Bram@vim.org>
parents: 22125
diff changeset
426 })
9d3dfd420a45 patch 8.2.1613: Vim9: cannot pass "true" to prop_type_add()
Bram Moolenaar <Bram@vim.org>
parents: 22125
diff changeset
427 prop_type_delete('comment')
9d3dfd420a45 patch 8.2.1613: Vim9: cannot pass "true" to prop_type_add()
Bram Moolenaar <Bram@vim.org>
parents: 22125
diff changeset
428 enddef
9d3dfd420a45 patch 8.2.1613: Vim9: cannot pass "true" to prop_type_add()
Bram Moolenaar <Bram@vim.org>
parents: 22125
diff changeset
429
22125
602e660d5ccf patch 8.2.1612: Vim9: cannot pass "true" to prop_remove()
Bram Moolenaar <Bram@vim.org>
parents: 22087
diff changeset
430 def Test_prop_remove_vim9()
602e660d5ccf patch 8.2.1612: Vim9: cannot pass "true" to prop_remove()
Bram Moolenaar <Bram@vim.org>
parents: 22087
diff changeset
431 new
27457
4c16acb2525f patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 26384
diff changeset
432 g:AddPropTypes()
4c16acb2525f patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 26384
diff changeset
433 g:SetupPropsInFirstLine()
23072
4b398a229b0b patch 8.2.2082: Vim9: can still use the depricated #{} dict syntax
Bram Moolenaar <Bram@vim.org>
parents: 22435
diff changeset
434 assert_equal(1, prop_remove({type: 'three', id: 13, both: true, all: true}))
27457
4c16acb2525f patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 26384
diff changeset
435 g:DeletePropTypes()
22125
602e660d5ccf patch 8.2.1612: Vim9: cannot pass "true" to prop_remove()
Bram Moolenaar <Bram@vim.org>
parents: 22087
diff changeset
436 bwipe!
602e660d5ccf patch 8.2.1612: Vim9: cannot pass "true" to prop_remove()
Bram Moolenaar <Bram@vim.org>
parents: 22087
diff changeset
437 enddef
602e660d5ccf patch 8.2.1612: Vim9: cannot pass "true" to prop_remove()
Bram Moolenaar <Bram@vim.org>
parents: 22087
diff changeset
438
15349
6abee072b93c patch 8.1.0682: text properties not adjusted when backspacing replaced text
Bram Moolenaar <Bram@vim.org>
parents: 15347
diff changeset
439 func SetupOneLine()
6abee072b93c patch 8.1.0682: text properties not adjusted when backspacing replaced text
Bram Moolenaar <Bram@vim.org>
parents: 15347
diff changeset
440 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
441 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
442 call AddPropTypes()
6abee072b93c patch 8.1.0682: text properties not adjusted when backspacing replaced text
Bram Moolenaar <Bram@vim.org>
parents: 15347
diff changeset
443 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
444 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
445 let expected = [
25392
b427a26b0210 patch 8.2.3233: prop_list() and prop_find() do not indicate the buffer
Bram Moolenaar <Bram@vim.org>
parents: 25198
diff changeset
446 \ #{type_bufnr: 0, col: 2, length: 3, id: 11, type: 'one', start: 1, end: 1},
b427a26b0210 patch 8.2.3233: prop_list() and prop_find() do not indicate the buffer
Bram Moolenaar <Bram@vim.org>
parents: 25198
diff changeset
447 \ #{type_bufnr: 0, col: 8, length: 3, id: 12, type: 'two', start: 1, end: 1},
15349
6abee072b93c patch 8.1.0682: text properties not adjusted when backspacing replaced text
Bram Moolenaar <Bram@vim.org>
parents: 15347
diff changeset
448 \]
6abee072b93c patch 8.1.0682: text properties not adjusted when backspacing replaced text
Bram Moolenaar <Bram@vim.org>
parents: 15347
diff changeset
449 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
450 return expected
6abee072b93c patch 8.1.0682: text properties not adjusted when backspacing replaced text
Bram Moolenaar <Bram@vim.org>
parents: 15347
diff changeset
451 endfunc
6abee072b93c patch 8.1.0682: text properties not adjusted when backspacing replaced text
Bram Moolenaar <Bram@vim.org>
parents: 15347
diff changeset
452
15138
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
453 func Test_prop_add_remove_buf()
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
454 new
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
455 let bufnr = bufnr('')
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
456 call AddPropTypes()
16060
176872829dc2 patch 8.1.1035: prop_remove() second argument is not optional
Bram Moolenaar <Bram@vim.org>
parents: 15928
diff changeset
457 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
458 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
459 endfor
15138
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
460 wincmd w
16060
176872829dc2 patch 8.1.1035: prop_remove() second argument is not optional
Bram Moolenaar <Bram@vim.org>
parents: 15928
diff changeset
461 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
462 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
463 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
464 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
465 endfor
176872829dc2 patch 8.1.1035: prop_remove() second argument is not optional
Bram Moolenaar <Bram@vim.org>
parents: 15928
diff changeset
466
15138
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
467 let props = [
25392
b427a26b0210 patch 8.2.3233: prop_list() and prop_find() do not indicate the buffer
Bram Moolenaar <Bram@vim.org>
parents: 25198
diff changeset
468 \ #{type_bufnr: 0, col: 1, length: 3, id: 11, type: 'one', start: 1, end: 1},
b427a26b0210 patch 8.2.3233: prop_list() and prop_find() do not indicate the buffer
Bram Moolenaar <Bram@vim.org>
parents: 25198
diff changeset
469 \ #{type_bufnr: 0, col: 5, length: 3, id: 12, type: 'two', start: 1, end: 1},
b427a26b0210 patch 8.2.3233: prop_list() and prop_find() do not indicate the buffer
Bram Moolenaar <Bram@vim.org>
parents: 25198
diff changeset
470 \ #{type_bufnr: 0, col: 11, length: 3, 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
471 \]
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
472 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
473
15138
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
474 " 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
475 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
476 unlet props[1]
176872829dc2 patch 8.1.1035: prop_remove() second argument is not optional
Bram Moolenaar <Bram@vim.org>
parents: 15928
diff changeset
477
15138
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
478 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
479 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
480 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
481 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
482 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
483
176872829dc2 patch 8.1.1035: prop_remove() second argument is not optional
Bram Moolenaar <Bram@vim.org>
parents: 15928
diff changeset
484 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
485 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
486 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
487 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
488 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
489
176872829dc2 patch 8.1.1035: prop_remove() second argument is not optional
Bram Moolenaar <Bram@vim.org>
parents: 15928
diff changeset
490 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
491 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
492 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
493 endfor
15138
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
494
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
495 " 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
496 let before_props = deepcopy(props)
15138
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
497 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
498
176872829dc2 patch 8.1.1035: prop_remove() second argument is not optional
Bram Moolenaar <Bram@vim.org>
parents: 15928
diff changeset
499 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
500 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
501 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
502 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
503 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
504
176872829dc2 patch 8.1.1035: prop_remove() second argument is not optional
Bram Moolenaar <Bram@vim.org>
parents: 15928
diff changeset
505 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
506 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
507 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
508 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
509 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
510
176872829dc2 patch 8.1.1035: prop_remove() second argument is not optional
Bram Moolenaar <Bram@vim.org>
parents: 15928
diff changeset
511 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
512 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
513 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
514 endfor
15138
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
515
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
516 call DeletePropTypes()
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
517 wincmd w
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
518 bwipe!
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
519 endfunc
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
520
15347
f6b522596993 patch 8.1.0681: text properties as not adjusted for deleted text
Bram Moolenaar <Bram@vim.org>
parents: 15341
diff changeset
521 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
522 new
f6b522596993 patch 8.1.0681: text properties as not adjusted for deleted text
Bram Moolenaar <Bram@vim.org>
parents: 15341
diff changeset
523 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
524 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
525
f6b522596993 patch 8.1.0681: text properties as not adjusted for deleted text
Bram Moolenaar <Bram@vim.org>
parents: 15341
diff changeset
526 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
527 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
528 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
529 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
530 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
531
f6b522596993 patch 8.1.0681: text properties as not adjusted for deleted text
Bram Moolenaar <Bram@vim.org>
parents: 15341
diff changeset
532 call DeletePropTypes()
f6b522596993 patch 8.1.0681: text properties as not adjusted for deleted text
Bram Moolenaar <Bram@vim.org>
parents: 15341
diff changeset
533 bwipe!
f6b522596993 patch 8.1.0681: text properties as not adjusted for deleted text
Bram Moolenaar <Bram@vim.org>
parents: 15341
diff changeset
534 set bs&
f6b522596993 patch 8.1.0681: text properties as not adjusted for deleted text
Bram Moolenaar <Bram@vim.org>
parents: 15341
diff changeset
535 endfunc
15138
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
536
28841
77a00aa3e215 patch 8.2.4944: text properties are wrong after "cc"
Bram Moolenaar <Bram@vim.org>
parents: 28526
diff changeset
537 func Test_prop_change()
77a00aa3e215 patch 8.2.4944: text properties are wrong after "cc"
Bram Moolenaar <Bram@vim.org>
parents: 28526
diff changeset
538 new
77a00aa3e215 patch 8.2.4944: text properties are wrong after "cc"
Bram Moolenaar <Bram@vim.org>
parents: 28526
diff changeset
539 let expected = SetupOneLine() " 'xonex xtwoxx'
77a00aa3e215 patch 8.2.4944: text properties are wrong after "cc"
Bram Moolenaar <Bram@vim.org>
parents: 28526
diff changeset
540
77a00aa3e215 patch 8.2.4944: text properties are wrong after "cc"
Bram Moolenaar <Bram@vim.org>
parents: 28526
diff changeset
541 " Characterwise.
77a00aa3e215 patch 8.2.4944: text properties are wrong after "cc"
Bram Moolenaar <Bram@vim.org>
parents: 28526
diff changeset
542 exe "normal 7|c$\<Esc>"
77a00aa3e215 patch 8.2.4944: text properties are wrong after "cc"
Bram Moolenaar <Bram@vim.org>
parents: 28526
diff changeset
543 call assert_equal('xonex ', getline(1))
77a00aa3e215 patch 8.2.4944: text properties are wrong after "cc"
Bram Moolenaar <Bram@vim.org>
parents: 28526
diff changeset
544 call assert_equal(expected[:0], prop_list(1))
77a00aa3e215 patch 8.2.4944: text properties are wrong after "cc"
Bram Moolenaar <Bram@vim.org>
parents: 28526
diff changeset
545 " Linewise.
77a00aa3e215 patch 8.2.4944: text properties are wrong after "cc"
Bram Moolenaar <Bram@vim.org>
parents: 28526
diff changeset
546 exe "normal cc\<Esc>"
77a00aa3e215 patch 8.2.4944: text properties are wrong after "cc"
Bram Moolenaar <Bram@vim.org>
parents: 28526
diff changeset
547 call assert_equal('', getline(1))
77a00aa3e215 patch 8.2.4944: text properties are wrong after "cc"
Bram Moolenaar <Bram@vim.org>
parents: 28526
diff changeset
548 call assert_equal([], prop_list(1))
77a00aa3e215 patch 8.2.4944: text properties are wrong after "cc"
Bram Moolenaar <Bram@vim.org>
parents: 28526
diff changeset
549
77a00aa3e215 patch 8.2.4944: text properties are wrong after "cc"
Bram Moolenaar <Bram@vim.org>
parents: 28526
diff changeset
550 call DeletePropTypes()
77a00aa3e215 patch 8.2.4944: text properties are wrong after "cc"
Bram Moolenaar <Bram@vim.org>
parents: 28526
diff changeset
551 bwipe!
77a00aa3e215 patch 8.2.4944: text properties are wrong after "cc"
Bram Moolenaar <Bram@vim.org>
parents: 28526
diff changeset
552 set bs&
77a00aa3e215 patch 8.2.4944: text properties are wrong after "cc"
Bram Moolenaar <Bram@vim.org>
parents: 28526
diff changeset
553 endfunc
77a00aa3e215 patch 8.2.4944: text properties are wrong after "cc"
Bram Moolenaar <Bram@vim.org>
parents: 28526
diff changeset
554
15349
6abee072b93c patch 8.1.0682: text properties not adjusted when backspacing replaced text
Bram Moolenaar <Bram@vim.org>
parents: 15347
diff changeset
555 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
556 new
6abee072b93c patch 8.1.0682: text properties not adjusted when backspacing replaced text
Bram Moolenaar <Bram@vim.org>
parents: 15347
diff changeset
557 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
558 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
559
6abee072b93c patch 8.1.0682: text properties not adjusted when backspacing replaced text
Bram Moolenaar <Bram@vim.org>
parents: 15347
diff changeset
560 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
561 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
562 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
563
6abee072b93c patch 8.1.0682: text properties not adjusted when backspacing replaced text
Bram Moolenaar <Bram@vim.org>
parents: 15347
diff changeset
564 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
565 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
566 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
567
6abee072b93c patch 8.1.0682: text properties not adjusted when backspacing replaced text
Bram Moolenaar <Bram@vim.org>
parents: 15347
diff changeset
568 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
569 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
570 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
571
6abee072b93c patch 8.1.0682: text properties not adjusted when backspacing replaced text
Bram Moolenaar <Bram@vim.org>
parents: 15347
diff changeset
572 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
573 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
574 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
575
28931
b57caac54649 patch 8.2.4988: textprop in wrong position when replacing multi-byte chars
Bram Moolenaar <Bram@vim.org>
parents: 28875
diff changeset
576 " Replace three 1-byte chars with three 2-byte ones.
b57caac54649 patch 8.2.4988: textprop in wrong position when replacing multi-byte chars
Bram Moolenaar <Bram@vim.org>
parents: 28875
diff changeset
577 exe "normal 0l3rø"
b57caac54649 patch 8.2.4988: textprop in wrong position when replacing multi-byte chars
Bram Moolenaar <Bram@vim.org>
parents: 28875
diff changeset
578 call assert_equal('yøøøx xyyoxx', getline(1))
b57caac54649 patch 8.2.4988: textprop in wrong position when replacing multi-byte chars
Bram Moolenaar <Bram@vim.org>
parents: 28875
diff changeset
579 let expected[0].length += 3
b57caac54649 patch 8.2.4988: textprop in wrong position when replacing multi-byte chars
Bram Moolenaar <Bram@vim.org>
parents: 28875
diff changeset
580 let expected[1].col += 3
b57caac54649 patch 8.2.4988: textprop in wrong position when replacing multi-byte chars
Bram Moolenaar <Bram@vim.org>
parents: 28875
diff changeset
581 call assert_equal(expected, prop_list(1))
b57caac54649 patch 8.2.4988: textprop in wrong position when replacing multi-byte chars
Bram Moolenaar <Bram@vim.org>
parents: 28875
diff changeset
582
15349
6abee072b93c patch 8.1.0682: text properties not adjusted when backspacing replaced text
Bram Moolenaar <Bram@vim.org>
parents: 15347
diff changeset
583 call DeletePropTypes()
6abee072b93c patch 8.1.0682: text properties not adjusted when backspacing replaced text
Bram Moolenaar <Bram@vim.org>
parents: 15347
diff changeset
584 bwipe!
6abee072b93c patch 8.1.0682: text properties not adjusted when backspacing replaced text
Bram Moolenaar <Bram@vim.org>
parents: 15347
diff changeset
585 set bs&
6abee072b93c patch 8.1.0682: text properties not adjusted when backspacing replaced text
Bram Moolenaar <Bram@vim.org>
parents: 15347
diff changeset
586 endfunc
6abee072b93c patch 8.1.0682: text properties not adjusted when backspacing replaced text
Bram Moolenaar <Bram@vim.org>
parents: 15347
diff changeset
587
16662
1fc9cd08cf3c patch 8.1.1333: text properties don't always move after changes
Bram Moolenaar <Bram@vim.org>
parents: 16545
diff changeset
588 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
589 new
1fc9cd08cf3c patch 8.1.1333: text properties don't always move after changes
Bram Moolenaar <Bram@vim.org>
parents: 16545
diff changeset
590
1fc9cd08cf3c patch 8.1.1333: text properties don't always move after changes
Bram Moolenaar <Bram@vim.org>
parents: 16545
diff changeset
591 " 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
592 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
593 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
594 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
595 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
596 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
597 call DeletePropTypes()
1fc9cd08cf3c patch 8.1.1333: text properties don't always move after changes
Bram Moolenaar <Bram@vim.org>
parents: 16545
diff changeset
598
1fc9cd08cf3c patch 8.1.1333: text properties don't always move after changes
Bram Moolenaar <Bram@vim.org>
parents: 16545
diff changeset
599 " 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
600 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
601 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
602 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
603 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
604 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
605 call DeletePropTypes()
1fc9cd08cf3c patch 8.1.1333: text properties don't always move after changes
Bram Moolenaar <Bram@vim.org>
parents: 16545
diff changeset
606
1fc9cd08cf3c patch 8.1.1333: text properties don't always move after changes
Bram Moolenaar <Bram@vim.org>
parents: 16545
diff changeset
607 " 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
608 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
609 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
610 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
611 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
612 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
613 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
614 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
615 call DeletePropTypes()
1fc9cd08cf3c patch 8.1.1333: text properties don't always move after changes
Bram Moolenaar <Bram@vim.org>
parents: 16545
diff changeset
616
1fc9cd08cf3c patch 8.1.1333: text properties don't always move after changes
Bram Moolenaar <Bram@vim.org>
parents: 16545
diff changeset
617 " 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
618 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
619 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
620 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
621 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
622 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
623 let exp_first[0].length = 1
20583
d067be761cd7 patch 8.2.0845: text properties crossing lines not handled correctly
Bram Moolenaar <Bram@vim.org>
parents: 20178
diff changeset
624 let exp_first[0].end = 0
16662
1fc9cd08cf3c patch 8.1.1333: text properties don't always move after changes
Bram Moolenaar <Bram@vim.org>
parents: 16545
diff changeset
625 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
626 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
627 let expected[0].length = 2
20583
d067be761cd7 patch 8.2.0845: text properties crossing lines not handled correctly
Bram Moolenaar <Bram@vim.org>
parents: 20178
diff changeset
628 let expected[0].start = 0
16662
1fc9cd08cf3c patch 8.1.1333: text properties don't always move after changes
Bram Moolenaar <Bram@vim.org>
parents: 16545
diff changeset
629 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
630 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
631 call DeletePropTypes()
1fc9cd08cf3c patch 8.1.1333: text properties don't always move after changes
Bram Moolenaar <Bram@vim.org>
parents: 16545
diff changeset
632
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
633 " 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
634 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
635 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
636 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
637 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
638 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
639 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
640 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
641 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
642 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
643 call DeletePropTypes()
1fc9cd08cf3c patch 8.1.1333: text properties don't always move after changes
Bram Moolenaar <Bram@vim.org>
parents: 16545
diff changeset
644
28865
a04815de0bd3 patch 8.2.4955: text property in wrong position after auto-indent
Bram Moolenaar <Bram@vim.org>
parents: 28863
diff changeset
645 " split at the space character with 'ai' active, the leading space is removed
a04815de0bd3 patch 8.2.4955: text property in wrong position after auto-indent
Bram Moolenaar <Bram@vim.org>
parents: 28863
diff changeset
646 " in the second line and the prop is shifted accordingly.
a04815de0bd3 patch 8.2.4955: text property in wrong position after auto-indent
Bram Moolenaar <Bram@vim.org>
parents: 28863
diff changeset
647 let expected = SetupOneLine() " 'xonex xtwoxx'
a04815de0bd3 patch 8.2.4955: text property in wrong position after auto-indent
Bram Moolenaar <Bram@vim.org>
parents: 28863
diff changeset
648 set ai
a04815de0bd3 patch 8.2.4955: text property in wrong position after auto-indent
Bram Moolenaar <Bram@vim.org>
parents: 28863
diff changeset
649 exe "normal 6|i\<CR>\<Esc>"
a04815de0bd3 patch 8.2.4955: text property in wrong position after auto-indent
Bram Moolenaar <Bram@vim.org>
parents: 28863
diff changeset
650 call assert_equal('xonex', getline(1))
a04815de0bd3 patch 8.2.4955: text property in wrong position after auto-indent
Bram Moolenaar <Bram@vim.org>
parents: 28863
diff changeset
651 call assert_equal('xtwoxx', getline(2))
a04815de0bd3 patch 8.2.4955: text property in wrong position after auto-indent
Bram Moolenaar <Bram@vim.org>
parents: 28863
diff changeset
652 let expected[1].col -= 6
a04815de0bd3 patch 8.2.4955: text property in wrong position after auto-indent
Bram Moolenaar <Bram@vim.org>
parents: 28863
diff changeset
653 call assert_equal(expected, prop_list(1) + prop_list(2))
a04815de0bd3 patch 8.2.4955: text property in wrong position after auto-indent
Bram Moolenaar <Bram@vim.org>
parents: 28863
diff changeset
654 set ai&
a04815de0bd3 patch 8.2.4955: text property in wrong position after auto-indent
Bram Moolenaar <Bram@vim.org>
parents: 28863
diff changeset
655 call DeletePropTypes()
a04815de0bd3 patch 8.2.4955: text property in wrong position after auto-indent
Bram Moolenaar <Bram@vim.org>
parents: 28863
diff changeset
656
16662
1fc9cd08cf3c patch 8.1.1333: text properties don't always move after changes
Bram Moolenaar <Bram@vim.org>
parents: 16545
diff changeset
657 bwipe!
1fc9cd08cf3c patch 8.1.1333: text properties don't always move after changes
Bram Moolenaar <Bram@vim.org>
parents: 16545
diff changeset
658 set bs&
1fc9cd08cf3c patch 8.1.1333: text properties don't always move after changes
Bram Moolenaar <Bram@vim.org>
parents: 16545
diff changeset
659 endfunc
1fc9cd08cf3c patch 8.1.1333: text properties don't always move after changes
Bram Moolenaar <Bram@vim.org>
parents: 16545
diff changeset
660
15138
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
661 func Test_prop_clear()
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
662 new
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
663 call AddPropTypes()
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
664 call SetupPropsInFirstLine()
15367
273649cad196 patch 8.1.0691: text properties are not adjusted for :substitute
Bram Moolenaar <Bram@vim.org>
parents: 15365
diff changeset
665 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
666
17980
52f23198af7f patch 8.1.1986: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17694
diff changeset
667 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
668 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
669
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
670 call DeletePropTypes()
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
671 bwipe!
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
672 endfunc
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
673
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
674 func Test_prop_clear_buf()
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
675 new
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
676 call AddPropTypes()
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
677 call SetupPropsInFirstLine()
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
678 let bufnr = bufnr('')
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
679 wincmd w
15367
273649cad196 patch 8.1.0691: text properties are not adjusted for :substitute
Bram Moolenaar <Bram@vim.org>
parents: 15365
diff changeset
680 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
681
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
682 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
683 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
684
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
685 wincmd w
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
686 call DeletePropTypes()
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
687 bwipe!
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
688 endfunc
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
689
15365
01ee8dc12313 patch 8.1.0690: setline() and setbufline() do not clear text properties
Bram Moolenaar <Bram@vim.org>
parents: 15363
diff changeset
690 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
691 new
01ee8dc12313 patch 8.1.0690: setline() and setbufline() do not clear text properties
Bram Moolenaar <Bram@vim.org>
parents: 15363
diff changeset
692 call AddPropTypes()
01ee8dc12313 patch 8.1.0690: setline() and setbufline() do not clear text properties
Bram Moolenaar <Bram@vim.org>
parents: 15363
diff changeset
693 call SetupPropsInFirstLine()
15367
273649cad196 patch 8.1.0691: text properties are not adjusted for :substitute
Bram Moolenaar <Bram@vim.org>
parents: 15365
diff changeset
694 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
695
01ee8dc12313 patch 8.1.0690: setline() and setbufline() do not clear text properties
Bram Moolenaar <Bram@vim.org>
parents: 15363
diff changeset
696 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
697 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
698
01ee8dc12313 patch 8.1.0690: setline() and setbufline() do not clear text properties
Bram Moolenaar <Bram@vim.org>
parents: 15363
diff changeset
699 call DeletePropTypes()
01ee8dc12313 patch 8.1.0690: setline() and setbufline() do not clear text properties
Bram Moolenaar <Bram@vim.org>
parents: 15363
diff changeset
700 bwipe!
01ee8dc12313 patch 8.1.0690: setline() and setbufline() do not clear text properties
Bram Moolenaar <Bram@vim.org>
parents: 15363
diff changeset
701 endfunc
01ee8dc12313 patch 8.1.0690: setline() and setbufline() do not clear text properties
Bram Moolenaar <Bram@vim.org>
parents: 15363
diff changeset
702
01ee8dc12313 patch 8.1.0690: setline() and setbufline() do not clear text properties
Bram Moolenaar <Bram@vim.org>
parents: 15363
diff changeset
703 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
704 new
01ee8dc12313 patch 8.1.0690: setline() and setbufline() do not clear text properties
Bram Moolenaar <Bram@vim.org>
parents: 15363
diff changeset
705 call AddPropTypes()
01ee8dc12313 patch 8.1.0690: setline() and setbufline() do not clear text properties
Bram Moolenaar <Bram@vim.org>
parents: 15363
diff changeset
706 call SetupPropsInFirstLine()
01ee8dc12313 patch 8.1.0690: setline() and setbufline() do not clear text properties
Bram Moolenaar <Bram@vim.org>
parents: 15363
diff changeset
707 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
708 wincmd w
15367
273649cad196 patch 8.1.0691: text properties are not adjusted for :substitute
Bram Moolenaar <Bram@vim.org>
parents: 15365
diff changeset
709 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
710
01ee8dc12313 patch 8.1.0690: setline() and setbufline() do not clear text properties
Bram Moolenaar <Bram@vim.org>
parents: 15363
diff changeset
711 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
712 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
713
01ee8dc12313 patch 8.1.0690: setline() and setbufline() do not clear text properties
Bram Moolenaar <Bram@vim.org>
parents: 15363
diff changeset
714 wincmd w
01ee8dc12313 patch 8.1.0690: setline() and setbufline() do not clear text properties
Bram Moolenaar <Bram@vim.org>
parents: 15363
diff changeset
715 call DeletePropTypes()
01ee8dc12313 patch 8.1.0690: setline() and setbufline() do not clear text properties
Bram Moolenaar <Bram@vim.org>
parents: 15363
diff changeset
716 bwipe!
01ee8dc12313 patch 8.1.0690: setline() and setbufline() do not clear text properties
Bram Moolenaar <Bram@vim.org>
parents: 15363
diff changeset
717 endfunc
01ee8dc12313 patch 8.1.0690: setline() and setbufline() do not clear text properties
Bram Moolenaar <Bram@vim.org>
parents: 15363
diff changeset
718
15367
273649cad196 patch 8.1.0691: text properties are not adjusted for :substitute
Bram Moolenaar <Bram@vim.org>
parents: 15365
diff changeset
719 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
720 new
273649cad196 patch 8.1.0691: text properties are not adjusted for :substitute
Bram Moolenaar <Bram@vim.org>
parents: 15365
diff changeset
721 " 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
722 call AddPropTypes()
273649cad196 patch 8.1.0691: text properties are not adjusted for :substitute
Bram Moolenaar <Bram@vim.org>
parents: 15365
diff changeset
723 call SetupPropsInFirstLine()
273649cad196 patch 8.1.0691: text properties are not adjusted for :substitute
Bram Moolenaar <Bram@vim.org>
parents: 15365
diff changeset
724 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
725 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
726
273649cad196 patch 8.1.0691: text properties are not adjusted for :substitute
Bram Moolenaar <Bram@vim.org>
parents: 15365
diff changeset
727 " 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
728 s/n/XX/
273649cad196 patch 8.1.0691: text properties are not adjusted for :substitute
Bram Moolenaar <Bram@vim.org>
parents: 15365
diff changeset
729 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
730 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
731 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
732 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
733 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
734
273649cad196 patch 8.1.0691: text properties are not adjusted for :substitute
Bram Moolenaar <Bram@vim.org>
parents: 15365
diff changeset
735 " 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
736 s/t//g
273649cad196 patch 8.1.0691: text properties are not adjusted for :substitute
Bram Moolenaar <Bram@vim.org>
parents: 15365
diff changeset
737 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
738 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
739 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
740 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
741 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
742
273649cad196 patch 8.1.0691: text properties are not adjusted for :substitute
Bram Moolenaar <Bram@vim.org>
parents: 15365
diff changeset
743 " 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
744 " 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
745 " 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
746 s/w/\r/
273649cad196 patch 8.1.0691: text properties are not adjusted for :substitute
Bram Moolenaar <Bram@vim.org>
parents: 15365
diff changeset
747 let new_props = [
273649cad196 patch 8.1.0691: text properties are not adjusted for :substitute
Bram Moolenaar <Bram@vim.org>
parents: 15365
diff changeset
748 \ 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
749 \ 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
750 \ 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
751 \ ]
273649cad196 patch 8.1.0691: text properties are not adjusted for :substitute
Bram Moolenaar <Bram@vim.org>
parents: 15365
diff changeset
752 let expected_props[0].length = 5
20583
d067be761cd7 patch 8.2.0845: text properties crossing lines not handled correctly
Bram Moolenaar <Bram@vim.org>
parents: 20178
diff changeset
753 let expected_props[0].end = 0
15367
273649cad196 patch 8.1.0691: text properties are not adjusted for :substitute
Bram Moolenaar <Bram@vim.org>
parents: 15365
diff changeset
754 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
755 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
756 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
757
273649cad196 patch 8.1.0691: text properties are not adjusted for :substitute
Bram Moolenaar <Bram@vim.org>
parents: 15365
diff changeset
758 let new_props[0].length = 6
20583
d067be761cd7 patch 8.2.0845: text properties crossing lines not handled correctly
Bram Moolenaar <Bram@vim.org>
parents: 20178
diff changeset
759 let new_props[0].start = 0
15367
273649cad196 patch 8.1.0691: text properties are not adjusted for :substitute
Bram Moolenaar <Bram@vim.org>
parents: 15365
diff changeset
760 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
761 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
762 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
763 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
764
273649cad196 patch 8.1.0691: text properties are not adjusted for :substitute
Bram Moolenaar <Bram@vim.org>
parents: 15365
diff changeset
765 call DeletePropTypes()
273649cad196 patch 8.1.0691: text properties are not adjusted for :substitute
Bram Moolenaar <Bram@vim.org>
parents: 15365
diff changeset
766 bwipe!
273649cad196 patch 8.1.0691: text properties are not adjusted for :substitute
Bram Moolenaar <Bram@vim.org>
parents: 15365
diff changeset
767 endfunc
273649cad196 patch 8.1.0691: text properties are not adjusted for :substitute
Bram Moolenaar <Bram@vim.org>
parents: 15365
diff changeset
768
15398
3e02464faaac patch 8.1.0707: text property columns are not adjusted for changed indent
Bram Moolenaar <Bram@vim.org>
parents: 15367
diff changeset
769 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
770 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
771 new
3e02464faaac patch 8.1.0707: text property columns are not adjusted for changed indent
Bram Moolenaar <Bram@vim.org>
parents: 15367
diff changeset
772 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
773 call prop_add(2, 2, {'length': 2, 'type': 'comment'})
25392
b427a26b0210 patch 8.2.3233: prop_list() and prop_find() do not indicate the buffer
Bram Moolenaar <Bram@vim.org>
parents: 25198
diff changeset
774 let expect = #{type_bufnr: 0, col: 2, length: 2, type: 'comment', start: 1, end: 1, id: 0}
15398
3e02464faaac patch 8.1.0707: text property columns are not adjusted for changed indent
Bram Moolenaar <Bram@vim.org>
parents: 15367
diff changeset
775 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
776
3e02464faaac patch 8.1.0707: text property columns are not adjusted for changed indent
Bram Moolenaar <Bram@vim.org>
parents: 15367
diff changeset
777 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
778 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
779 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
780 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
781 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
782
3e02464faaac patch 8.1.0707: text property columns are not adjusted for changed indent
Bram Moolenaar <Bram@vim.org>
parents: 15367
diff changeset
783 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
784 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
785 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
786 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
787
3e02464faaac patch 8.1.0707: text property columns are not adjusted for changed indent
Bram Moolenaar <Bram@vim.org>
parents: 15367
diff changeset
788 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
789 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
790 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
791 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
792 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
793
3e02464faaac patch 8.1.0707: text property columns are not adjusted for changed indent
Bram Moolenaar <Bram@vim.org>
parents: 15367
diff changeset
794 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
795 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
796 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
797 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
798
3e02464faaac patch 8.1.0707: text property columns are not adjusted for changed indent
Bram Moolenaar <Bram@vim.org>
parents: 15367
diff changeset
799 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
800 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
801 endfunc
3e02464faaac patch 8.1.0707: text property columns are not adjusted for changed indent
Bram Moolenaar <Bram@vim.org>
parents: 15367
diff changeset
802
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
803 " 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
804 " 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
805 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
806 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
807 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
808 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
809 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
810 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
811 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
812
15251
17525ca95e1e patch 8.1.0634: text properties cannot cross line boundaries
Bram Moolenaar <Bram@vim.org>
parents: 15138
diff changeset
813 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
814 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
815 new
17525ca95e1e patch 8.1.0634: text properties cannot cross line boundaries
Bram Moolenaar <Bram@vim.org>
parents: 15138
diff changeset
816 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
817
17525ca95e1e patch 8.1.0634: text properties cannot cross line boundaries
Bram Moolenaar <Bram@vim.org>
parents: 15138
diff changeset
818 " 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
819 call prop_add(1, 3, {'end_lnum': 3, 'end_col': 5, 'type': 'comment'})
25392
b427a26b0210 patch 8.2.3233: prop_list() and prop_find() do not indicate the buffer
Bram Moolenaar <Bram@vim.org>
parents: 25198
diff changeset
820 let expect1 = #{type_bufnr: 0, col: 3, length: 6, type: 'comment', start: 1, end: 0, id: 0}
15251
17525ca95e1e patch 8.1.0634: text properties cannot cross line boundaries
Bram Moolenaar <Bram@vim.org>
parents: 15138
diff changeset
821 call assert_equal([expect1], prop_list(1))
25392
b427a26b0210 patch 8.2.3233: prop_list() and prop_find() do not indicate the buffer
Bram Moolenaar <Bram@vim.org>
parents: 25198
diff changeset
822 let expect2 = #{type_bufnr: 0, col: 1, length: 10, type: 'comment', start: 0, end: 0, id: 0}
15251
17525ca95e1e patch 8.1.0634: text properties cannot cross line boundaries
Bram Moolenaar <Bram@vim.org>
parents: 15138
diff changeset
823 call assert_equal([expect2], prop_list(2))
25392
b427a26b0210 patch 8.2.3233: prop_list() and prop_find() do not indicate the buffer
Bram Moolenaar <Bram@vim.org>
parents: 25198
diff changeset
824 let expect3 = #{type_bufnr: 0, 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
825 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
826 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
827
17525ca95e1e patch 8.1.0634: text properties cannot cross line boundaries
Bram Moolenaar <Bram@vim.org>
parents: 15138
diff changeset
828 " include all three lines
17525ca95e1e patch 8.1.0634: text properties cannot cross line boundaries
Bram Moolenaar <Bram@vim.org>
parents: 15138
diff changeset
829 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
830 let expect1.col = 1
17525ca95e1e patch 8.1.0634: text properties cannot cross line boundaries
Bram Moolenaar <Bram@vim.org>
parents: 15138
diff changeset
831 let expect1.length = 8
17525ca95e1e patch 8.1.0634: text properties cannot cross line boundaries
Bram Moolenaar <Bram@vim.org>
parents: 15138
diff changeset
832 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
833 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
834 let expect3.length = 9
17525ca95e1e patch 8.1.0634: text properties cannot cross line boundaries
Bram Moolenaar <Bram@vim.org>
parents: 15138
diff changeset
835 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
836 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
837
17525ca95e1e patch 8.1.0634: text properties cannot cross line boundaries
Bram Moolenaar <Bram@vim.org>
parents: 15138
diff changeset
838 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
839
15335
18c20ceee4b5 patch 8.1.0675: text property column in screen columns is not practical
Bram Moolenaar <Bram@vim.org>
parents: 15318
diff changeset
840 " 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
841 call Setup_three_line_prop()
25392
b427a26b0210 patch 8.2.3233: prop_list() and prop_find() do not indicate the buffer
Bram Moolenaar <Bram@vim.org>
parents: 25198
diff changeset
842 let expect_short = #{type_bufnr: 0, col: 2, length: 1, type: 'comment', start: 1, end: 1, id: 0}
15335
18c20ceee4b5 patch 8.1.0675: text property column in screen columns is not practical
Bram Moolenaar <Bram@vim.org>
parents: 15318
diff changeset
843 call assert_equal([expect_short], prop_list(1))
25392
b427a26b0210 patch 8.2.3233: prop_list() and prop_find() do not indicate the buffer
Bram Moolenaar <Bram@vim.org>
parents: 25198
diff changeset
844 let expect2 = #{type_bufnr: 0, col: 4, length: 4, type: 'comment', start: 1, end: 0, 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
845 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
846 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
847 call assert_equal([expect_short], prop_list(1))
25392
b427a26b0210 patch 8.2.3233: prop_list() and prop_find() do not indicate the buffer
Bram Moolenaar <Bram@vim.org>
parents: 25198
diff changeset
848 let expect2 = #{type_bufnr: 0, col: 1, length: 6, type: 'comment', start: 1, end: 0, 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
849 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
850 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
851
15335
18c20ceee4b5 patch 8.1.0675: text property column in screen columns is not practical
Bram Moolenaar <Bram@vim.org>
parents: 15318
diff changeset
852 " 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
853 call Setup_three_line_prop()
25392
b427a26b0210 patch 8.2.3233: prop_list() and prop_find() do not indicate the buffer
Bram Moolenaar <Bram@vim.org>
parents: 25198
diff changeset
854 let expect3 = #{type_bufnr: 0, col: 1, length: 6, type: 'comment', start: 0, end: 0, 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
855 call assert_equal([expect3], prop_list(3))
25392
b427a26b0210 patch 8.2.3233: prop_list() and prop_find() do not indicate the buffer
Bram Moolenaar <Bram@vim.org>
parents: 25198
diff changeset
856 let expect4 = #{type_bufnr: 0, 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
857 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
858 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
859 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
860 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
861 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
862 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
863
15335
18c20ceee4b5 patch 8.1.0675: text property column in screen columns is not practical
Bram Moolenaar <Bram@vim.org>
parents: 15318
diff changeset
864 " 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
865 call Setup_three_line_prop()
25392
b427a26b0210 patch 8.2.3233: prop_list() and prop_find() do not indicate the buffer
Bram Moolenaar <Bram@vim.org>
parents: 25198
diff changeset
866 let expect2 = #{type_bufnr: 0, col: 4, length: 4, type: 'comment', start: 1, end: 0, id: 0}
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
867 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
868 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
869 call assert_equal([expect2], prop_list(2))
25392
b427a26b0210 patch 8.2.3233: prop_list() and prop_find() do not indicate the buffer
Bram Moolenaar <Bram@vim.org>
parents: 25198
diff changeset
870 let expect3 = #{type_bufnr: 0, col: 1, length: 9, type: 'comment', start: 0, end: 0, id: 0}
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
871 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
872 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
873
15251
17525ca95e1e patch 8.1.0634: text properties cannot cross line boundaries
Bram Moolenaar <Bram@vim.org>
parents: 15138
diff changeset
874 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
875 endfunc
17525ca95e1e patch 8.1.0634: text properties cannot cross line boundaries
Bram Moolenaar <Bram@vim.org>
parents: 15138
diff changeset
876
19110
e40814841406 patch 8.2.0115: byte2line() does not work correctly with text properties
Bram Moolenaar <Bram@vim.org>
parents: 19100
diff changeset
877 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
878 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
879 new
15269
27783a6f430b patch 8.1.0643: computing byte offset wrong
Bram Moolenaar <Bram@vim.org>
parents: 15261
diff changeset
880 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
881 set ff=unix
15269
27783a6f430b patch 8.1.0643: computing byte offset wrong
Bram Moolenaar <Bram@vim.org>
parents: 15261
diff changeset
882 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
883 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
884 call assert_equal(19, line2byte(3))
25624
0ef8ef1af478 patch 8.2.3348: line2byte() returns wrong value after adding textprop
Bram Moolenaar <Bram@vim.org>
parents: 25471
diff changeset
885 bwipe!
15255
19e79a1ed6b6 patch 8.1.0636: line2byte() gives wrong values with text properties
Bram Moolenaar <Bram@vim.org>
parents: 15251
diff changeset
886
25624
0ef8ef1af478 patch 8.2.3348: line2byte() returns wrong value after adding textprop
Bram Moolenaar <Bram@vim.org>
parents: 25471
diff changeset
887 new
25628
0407a3db3ef6 patch 8.2.3350: text properties test fails on MS-Windows
Bram Moolenaar <Bram@vim.org>
parents: 25624
diff changeset
888 setlocal ff=unix
25624
0ef8ef1af478 patch 8.2.3348: line2byte() returns wrong value after adding textprop
Bram Moolenaar <Bram@vim.org>
parents: 25471
diff changeset
889 call setline(1, range(500))
0ef8ef1af478 patch 8.2.3348: line2byte() returns wrong value after adding textprop
Bram Moolenaar <Bram@vim.org>
parents: 25471
diff changeset
890 call assert_equal(1491, line2byte(401))
0ef8ef1af478 patch 8.2.3348: line2byte() returns wrong value after adding textprop
Bram Moolenaar <Bram@vim.org>
parents: 25471
diff changeset
891 call prop_add(2, 1, {'type': 'comment'})
0ef8ef1af478 patch 8.2.3348: line2byte() returns wrong value after adding textprop
Bram Moolenaar <Bram@vim.org>
parents: 25471
diff changeset
892 call prop_add(222, 1, {'type': 'comment'})
0ef8ef1af478 patch 8.2.3348: line2byte() returns wrong value after adding textprop
Bram Moolenaar <Bram@vim.org>
parents: 25471
diff changeset
893 call assert_equal(1491, line2byte(401))
0ef8ef1af478 patch 8.2.3348: line2byte() returns wrong value after adding textprop
Bram Moolenaar <Bram@vim.org>
parents: 25471
diff changeset
894 call prop_remove({'type': 'comment'})
0ef8ef1af478 patch 8.2.3348: line2byte() returns wrong value after adding textprop
Bram Moolenaar <Bram@vim.org>
parents: 25471
diff changeset
895 call assert_equal(1491, line2byte(401))
15255
19e79a1ed6b6 patch 8.1.0636: line2byte() gives wrong values with text properties
Bram Moolenaar <Bram@vim.org>
parents: 15251
diff changeset
896 bwipe!
25624
0ef8ef1af478 patch 8.2.3348: line2byte() returns wrong value after adding textprop
Bram Moolenaar <Bram@vim.org>
parents: 25471
diff changeset
897
25672
ab42c36d1a27 patch 8.2.3372: line2byte() value wrong when adding a text property
Bram Moolenaar <Bram@vim.org>
parents: 25640
diff changeset
898 new
25674
1d14b5d3de17 patch 8.2.3373: text property test fails on MS-Windows
Bram Moolenaar <Bram@vim.org>
parents: 25672
diff changeset
899 setlocal ff=unix
25672
ab42c36d1a27 patch 8.2.3372: line2byte() value wrong when adding a text property
Bram Moolenaar <Bram@vim.org>
parents: 25640
diff changeset
900 call setline(1, range(520))
ab42c36d1a27 patch 8.2.3372: line2byte() value wrong when adding a text property
Bram Moolenaar <Bram@vim.org>
parents: 25640
diff changeset
901 call assert_equal(1491, line2byte(401))
ab42c36d1a27 patch 8.2.3372: line2byte() value wrong when adding a text property
Bram Moolenaar <Bram@vim.org>
parents: 25640
diff changeset
902 call prop_add(2, 1, {'type': 'comment'})
ab42c36d1a27 patch 8.2.3372: line2byte() value wrong when adding a text property
Bram Moolenaar <Bram@vim.org>
parents: 25640
diff changeset
903 call assert_equal(1491, line2byte(401))
ab42c36d1a27 patch 8.2.3372: line2byte() value wrong when adding a text property
Bram Moolenaar <Bram@vim.org>
parents: 25640
diff changeset
904 2delete
ab42c36d1a27 patch 8.2.3372: line2byte() value wrong when adding a text property
Bram Moolenaar <Bram@vim.org>
parents: 25640
diff changeset
905 call assert_equal(1489, line2byte(400))
ab42c36d1a27 patch 8.2.3372: line2byte() value wrong when adding a text property
Bram Moolenaar <Bram@vim.org>
parents: 25640
diff changeset
906 bwipe!
ab42c36d1a27 patch 8.2.3372: line2byte() value wrong when adding a text property
Bram Moolenaar <Bram@vim.org>
parents: 25640
diff changeset
907
15255
19e79a1ed6b6 patch 8.1.0636: line2byte() gives wrong values with text properties
Bram Moolenaar <Bram@vim.org>
parents: 15251
diff changeset
908 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
909 endfunc
19e79a1ed6b6 patch 8.1.0636: line2byte() gives wrong values with text properties
Bram Moolenaar <Bram@vim.org>
parents: 15251
diff changeset
910
19110
e40814841406 patch 8.2.0115: byte2line() does not work correctly with text properties
Bram Moolenaar <Bram@vim.org>
parents: 19100
diff changeset
911 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
912 new
e40814841406 patch 8.2.0115: byte2line() does not work correctly with text properties
Bram Moolenaar <Bram@vim.org>
parents: 19100
diff changeset
913 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
914 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
915 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
916 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
917
e40814841406 patch 8.2.0115: byte2line() does not work correctly with text properties
Bram Moolenaar <Bram@vim.org>
parents: 19100
diff changeset
918 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
919 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
920 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
921 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
922
e40814841406 patch 8.2.0115: byte2line() does not work correctly with text properties
Bram Moolenaar <Bram@vim.org>
parents: 19100
diff changeset
923 bwipe!
e40814841406 patch 8.2.0115: byte2line() does not work correctly with text properties
Bram Moolenaar <Bram@vim.org>
parents: 19100
diff changeset
924 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
925 endfunc
e40814841406 patch 8.2.0115: byte2line() does not work correctly with text properties
Bram Moolenaar <Bram@vim.org>
parents: 19100
diff changeset
926
23776
9f692a75d481 patch 8.2.2429: :goto does not work correctly with text properties
Bram Moolenaar <Bram@vim.org>
parents: 23306
diff changeset
927 func Test_prop_goto_byte()
9f692a75d481 patch 8.2.2429: :goto does not work correctly with text properties
Bram Moolenaar <Bram@vim.org>
parents: 23306
diff changeset
928 new
9f692a75d481 patch 8.2.2429: :goto does not work correctly with text properties
Bram Moolenaar <Bram@vim.org>
parents: 23306
diff changeset
929 call setline(1, '')
9f692a75d481 patch 8.2.2429: :goto does not work correctly with text properties
Bram Moolenaar <Bram@vim.org>
parents: 23306
diff changeset
930 call setline(2, 'two three')
9f692a75d481 patch 8.2.2429: :goto does not work correctly with text properties
Bram Moolenaar <Bram@vim.org>
parents: 23306
diff changeset
931 call setline(3, '')
9f692a75d481 patch 8.2.2429: :goto does not work correctly with text properties
Bram Moolenaar <Bram@vim.org>
parents: 23306
diff changeset
932 call setline(4, 'four five')
9f692a75d481 patch 8.2.2429: :goto does not work correctly with text properties
Bram Moolenaar <Bram@vim.org>
parents: 23306
diff changeset
933
9f692a75d481 patch 8.2.2429: :goto does not work correctly with text properties
Bram Moolenaar <Bram@vim.org>
parents: 23306
diff changeset
934 call prop_type_add('testprop', {'highlight': 'Directory'})
9f692a75d481 patch 8.2.2429: :goto does not work correctly with text properties
Bram Moolenaar <Bram@vim.org>
parents: 23306
diff changeset
935 call search('^two')
9f692a75d481 patch 8.2.2429: :goto does not work correctly with text properties
Bram Moolenaar <Bram@vim.org>
parents: 23306
diff changeset
936 call prop_add(line('.'), col('.'), {
9f692a75d481 patch 8.2.2429: :goto does not work correctly with text properties
Bram Moolenaar <Bram@vim.org>
parents: 23306
diff changeset
937 \ 'length': len('two'),
9f692a75d481 patch 8.2.2429: :goto does not work correctly with text properties
Bram Moolenaar <Bram@vim.org>
parents: 23306
diff changeset
938 \ 'type': 'testprop'
9f692a75d481 patch 8.2.2429: :goto does not work correctly with text properties
Bram Moolenaar <Bram@vim.org>
parents: 23306
diff changeset
939 \ })
9f692a75d481 patch 8.2.2429: :goto does not work correctly with text properties
Bram Moolenaar <Bram@vim.org>
parents: 23306
diff changeset
940
9f692a75d481 patch 8.2.2429: :goto does not work correctly with text properties
Bram Moolenaar <Bram@vim.org>
parents: 23306
diff changeset
941 call search('two \zsthree')
9f692a75d481 patch 8.2.2429: :goto does not work correctly with text properties
Bram Moolenaar <Bram@vim.org>
parents: 23306
diff changeset
942 let expected_pos = line2byte(line('.')) + col('.') - 1
9f692a75d481 patch 8.2.2429: :goto does not work correctly with text properties
Bram Moolenaar <Bram@vim.org>
parents: 23306
diff changeset
943 exe expected_pos .. 'goto'
9f692a75d481 patch 8.2.2429: :goto does not work correctly with text properties
Bram Moolenaar <Bram@vim.org>
parents: 23306
diff changeset
944 let actual_pos = line2byte(line('.')) + col('.') - 1
9f692a75d481 patch 8.2.2429: :goto does not work correctly with text properties
Bram Moolenaar <Bram@vim.org>
parents: 23306
diff changeset
945 eval actual_pos->assert_equal(expected_pos)
9f692a75d481 patch 8.2.2429: :goto does not work correctly with text properties
Bram Moolenaar <Bram@vim.org>
parents: 23306
diff changeset
946
9f692a75d481 patch 8.2.2429: :goto does not work correctly with text properties
Bram Moolenaar <Bram@vim.org>
parents: 23306
diff changeset
947 call search('four \zsfive')
9f692a75d481 patch 8.2.2429: :goto does not work correctly with text properties
Bram Moolenaar <Bram@vim.org>
parents: 23306
diff changeset
948 let expected_pos = line2byte(line('.')) + col('.') - 1
9f692a75d481 patch 8.2.2429: :goto does not work correctly with text properties
Bram Moolenaar <Bram@vim.org>
parents: 23306
diff changeset
949 exe expected_pos .. 'goto'
9f692a75d481 patch 8.2.2429: :goto does not work correctly with text properties
Bram Moolenaar <Bram@vim.org>
parents: 23306
diff changeset
950 let actual_pos = line2byte(line('.')) + col('.') - 1
9f692a75d481 patch 8.2.2429: :goto does not work correctly with text properties
Bram Moolenaar <Bram@vim.org>
parents: 23306
diff changeset
951 eval actual_pos->assert_equal(expected_pos)
9f692a75d481 patch 8.2.2429: :goto does not work correctly with text properties
Bram Moolenaar <Bram@vim.org>
parents: 23306
diff changeset
952
9f692a75d481 patch 8.2.2429: :goto does not work correctly with text properties
Bram Moolenaar <Bram@vim.org>
parents: 23306
diff changeset
953 call prop_type_delete('testprop')
9f692a75d481 patch 8.2.2429: :goto does not work correctly with text properties
Bram Moolenaar <Bram@vim.org>
parents: 23306
diff changeset
954 bwipe!
9f692a75d481 patch 8.2.2429: :goto does not work correctly with text properties
Bram Moolenaar <Bram@vim.org>
parents: 23306
diff changeset
955 endfunc
9f692a75d481 patch 8.2.2429: :goto does not work correctly with text properties
Bram Moolenaar <Bram@vim.org>
parents: 23306
diff changeset
956
15363
45f36b66a032 patch 8.1.0689: undo with text properties not tested
Bram Moolenaar <Bram@vim.org>
parents: 15349
diff changeset
957 func Test_prop_undo()
45f36b66a032 patch 8.1.0689: undo with text properties not tested
Bram Moolenaar <Bram@vim.org>
parents: 15349
diff changeset
958 new
45f36b66a032 patch 8.1.0689: undo with text properties not tested
Bram Moolenaar <Bram@vim.org>
parents: 15349
diff changeset
959 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
960 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
961 " 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
962 set ul&
45f36b66a032 patch 8.1.0689: undo with text properties not tested
Bram Moolenaar <Bram@vim.org>
parents: 15349
diff changeset
963
45f36b66a032 patch 8.1.0689: undo with text properties not tested
Bram Moolenaar <Bram@vim.org>
parents: 15349
diff changeset
964 call prop_add(1, 3, {'end_col': 5, 'type': 'comment'})
25392
b427a26b0210 patch 8.2.3233: prop_list() and prop_find() do not indicate the buffer
Bram Moolenaar <Bram@vim.org>
parents: 25198
diff changeset
965 let expected = [#{type_bufnr: 0, col: 3, length: 2, id: 0, type: 'comment', start: 1, end: 1}]
15363
45f36b66a032 patch 8.1.0689: undo with text properties not tested
Bram Moolenaar <Bram@vim.org>
parents: 15349
diff changeset
966 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
967
45f36b66a032 patch 8.1.0689: undo with text properties not tested
Bram Moolenaar <Bram@vim.org>
parents: 15349
diff changeset
968 " 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
969 exe "normal 0lllix\<Esc>"
45f36b66a032 patch 8.1.0689: undo with text properties not tested
Bram Moolenaar <Bram@vim.org>
parents: 15349
diff changeset
970 set ul&
45f36b66a032 patch 8.1.0689: undo with text properties not tested
Bram Moolenaar <Bram@vim.org>
parents: 15349
diff changeset
971 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
972 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
973 undo
45f36b66a032 patch 8.1.0689: undo with text properties not tested
Bram Moolenaar <Bram@vim.org>
parents: 15349
diff changeset
974 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
975 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
976
45f36b66a032 patch 8.1.0689: undo with text properties not tested
Bram Moolenaar <Bram@vim.org>
parents: 15349
diff changeset
977 " 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
978 exe "normal 0lllx"
45f36b66a032 patch 8.1.0689: undo with text properties not tested
Bram Moolenaar <Bram@vim.org>
parents: 15349
diff changeset
979 set ul&
45f36b66a032 patch 8.1.0689: undo with text properties not tested
Bram Moolenaar <Bram@vim.org>
parents: 15349
diff changeset
980 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
981 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
982 undo
45f36b66a032 patch 8.1.0689: undo with text properties not tested
Bram Moolenaar <Bram@vim.org>
parents: 15349
diff changeset
983 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
984 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
985
45f36b66a032 patch 8.1.0689: undo with text properties not tested
Bram Moolenaar <Bram@vim.org>
parents: 15349
diff changeset
986 " 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
987 1d
45f36b66a032 patch 8.1.0689: undo with text properties not tested
Bram Moolenaar <Bram@vim.org>
parents: 15349
diff changeset
988 set ul&
45f36b66a032 patch 8.1.0689: undo with text properties not tested
Bram Moolenaar <Bram@vim.org>
parents: 15349
diff changeset
989 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
990 undo
45f36b66a032 patch 8.1.0689: undo with text properties not tested
Bram Moolenaar <Bram@vim.org>
parents: 15349
diff changeset
991 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
992
45f36b66a032 patch 8.1.0689: undo with text properties not tested
Bram Moolenaar <Bram@vim.org>
parents: 15349
diff changeset
993 " 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
994 exe "normal 0lllix\<Esc>"
45f36b66a032 patch 8.1.0689: undo with text properties not tested
Bram Moolenaar <Bram@vim.org>
parents: 15349
diff changeset
995 set ul&
45f36b66a032 patch 8.1.0689: undo with text properties not tested
Bram Moolenaar <Bram@vim.org>
parents: 15349
diff changeset
996 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
997 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
998 exe "normal 0lllxx"
45f36b66a032 patch 8.1.0689: undo with text properties not tested
Bram Moolenaar <Bram@vim.org>
parents: 15349
diff changeset
999 set ul&
45f36b66a032 patch 8.1.0689: undo with text properties not tested
Bram Moolenaar <Bram@vim.org>
parents: 15349
diff changeset
1000 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
1001 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
1002 normal U
45f36b66a032 patch 8.1.0689: undo with text properties not tested
Bram Moolenaar <Bram@vim.org>
parents: 15349
diff changeset
1003 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
1004 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
1005
16698
23af483c4ceb patch 8.1.1351: text property wrong after :substitute
Bram Moolenaar <Bram@vim.org>
parents: 16682
diff changeset
1006 " substitute a word, then undo
23af483c4ceb patch 8.1.1351: text property wrong after :substitute
Bram Moolenaar <Bram@vim.org>
parents: 16682
diff changeset
1007 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
1008 call prop_add(1, 12, {'length': 3, 'type': 'comment'})
25392
b427a26b0210 patch 8.2.3233: prop_list() and prop_find() do not indicate the buffer
Bram Moolenaar <Bram@vim.org>
parents: 25198
diff changeset
1009 let expected = [#{type_bufnr: 0, col: 12, length: 3, id: 0, type: 'comment', start: 1, end: 1} ]
16698
23af483c4ceb patch 8.1.1351: text property wrong after :substitute
Bram Moolenaar <Bram@vim.org>
parents: 16682
diff changeset
1010 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
1011 set ul&
23af483c4ceb patch 8.1.1351: text property wrong after :substitute
Bram Moolenaar <Bram@vim.org>
parents: 16682
diff changeset
1012 1s/number/foo
23af483c4ceb patch 8.1.1351: text property wrong after :substitute
Bram Moolenaar <Bram@vim.org>
parents: 16682
diff changeset
1013 let expected[0].col = 9
23af483c4ceb patch 8.1.1351: text property wrong after :substitute
Bram Moolenaar <Bram@vim.org>
parents: 16682
diff changeset
1014 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
1015 undo
23af483c4ceb patch 8.1.1351: text property wrong after :substitute
Bram Moolenaar <Bram@vim.org>
parents: 16682
diff changeset
1016 let expected[0].col = 12
23af483c4ceb patch 8.1.1351: text property wrong after :substitute
Bram Moolenaar <Bram@vim.org>
parents: 16682
diff changeset
1017 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
1018 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
1019
ba592f30c082 patch 8.1.1359: text property wrong after :substitute with backslash
Bram Moolenaar <Bram@vim.org>
parents: 16698
diff changeset
1020 " substitute with backslash
ba592f30c082 patch 8.1.1359: text property wrong after :substitute with backslash
Bram Moolenaar <Bram@vim.org>
parents: 16698
diff changeset
1021 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
1022 call prop_add(1, 12, {'length': 3, 'type': 'comment'})
25392
b427a26b0210 patch 8.2.3233: prop_list() and prop_find() do not indicate the buffer
Bram Moolenaar <Bram@vim.org>
parents: 25198
diff changeset
1023 let expected = [#{type_bufnr: 0, col: 12, length: 3, id: 0, type: 'comment', start: 1, end: 1} ]
16714
ba592f30c082 patch 8.1.1359: text property wrong after :substitute with backslash
Bram Moolenaar <Bram@vim.org>
parents: 16698
diff changeset
1024 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
1025 1s/the/\The
ba592f30c082 patch 8.1.1359: text property wrong after :substitute with backslash
Bram Moolenaar <Bram@vim.org>
parents: 16698
diff changeset
1026 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
1027 1s/^/\\
ba592f30c082 patch 8.1.1359: text property wrong after :substitute with backslash
Bram Moolenaar <Bram@vim.org>
parents: 16698
diff changeset
1028 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
1029 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
1030 1s/^/\~
ba592f30c082 patch 8.1.1359: text property wrong after :substitute with backslash
Bram Moolenaar <Bram@vim.org>
parents: 16698
diff changeset
1031 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
1032 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
1033 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
1034 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
1035 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
1036 call prop_clear(1)
16698
23af483c4ceb patch 8.1.1351: text property wrong after :substitute
Bram Moolenaar <Bram@vim.org>
parents: 16682
diff changeset
1037
15363
45f36b66a032 patch 8.1.0689: undo with text properties not tested
Bram Moolenaar <Bram@vim.org>
parents: 15349
diff changeset
1038 bwipe!
45f36b66a032 patch 8.1.0689: undo with text properties not tested
Bram Moolenaar <Bram@vim.org>
parents: 15349
diff changeset
1039 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
1040 endfunc
45f36b66a032 patch 8.1.0689: undo with text properties not tested
Bram Moolenaar <Bram@vim.org>
parents: 15349
diff changeset
1041
18631
e2d9f4d030fa patch 8.1.2308: deleting text before zero-width textprop removes it
Bram Moolenaar <Bram@vim.org>
parents: 18605
diff changeset
1042 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
1043 new
e2d9f4d030fa patch 8.1.2308: deleting text before zero-width textprop removes it
Bram Moolenaar <Bram@vim.org>
parents: 18605
diff changeset
1044 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
1045 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
1046
e2d9f4d030fa patch 8.1.2308: deleting text before zero-width textprop removes it
Bram Moolenaar <Bram@vim.org>
parents: 18605
diff changeset
1047 " 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
1048 call prop_add(1, 3, {'type': 'comment'})
25392
b427a26b0210 patch 8.2.3233: prop_list() and prop_find() do not indicate the buffer
Bram Moolenaar <Bram@vim.org>
parents: 25198
diff changeset
1049 let expected = [#{type_bufnr: 0, col: 3, length: 0, id: 0, type: 'comment', start: 1, end: 1} ]
18631
e2d9f4d030fa patch 8.1.2308: deleting text before zero-width textprop removes it
Bram Moolenaar <Bram@vim.org>
parents: 18605
diff changeset
1050 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
1051
e2d9f4d030fa patch 8.1.2308: deleting text before zero-width textprop removes it
Bram Moolenaar <Bram@vim.org>
parents: 18605
diff changeset
1052 " 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
1053 normal! x
25392
b427a26b0210 patch 8.2.3233: prop_list() and prop_find() do not indicate the buffer
Bram Moolenaar <Bram@vim.org>
parents: 25198
diff changeset
1054 let expected = [#{type_bufnr: 0, col: 2, length: 0, id: 0, type: 'comment', start: 1, end: 1} ]
18631
e2d9f4d030fa patch 8.1.2308: deleting text before zero-width textprop removes it
Bram Moolenaar <Bram@vim.org>
parents: 18605
diff changeset
1055 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
1056
e2d9f4d030fa patch 8.1.2308: deleting text before zero-width textprop removes it
Bram Moolenaar <Bram@vim.org>
parents: 18605
diff changeset
1057 " 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
1058 normal! lx
25392
b427a26b0210 patch 8.2.3233: prop_list() and prop_find() do not indicate the buffer
Bram Moolenaar <Bram@vim.org>
parents: 25198
diff changeset
1059 let expected = [#{type_bufnr: 0, col: 2, length: 0, id: 0, type: 'comment', start: 1, end: 1} ]
18631
e2d9f4d030fa patch 8.1.2308: deleting text before zero-width textprop removes it
Bram Moolenaar <Bram@vim.org>
parents: 18605
diff changeset
1060 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
1061
e2d9f4d030fa patch 8.1.2308: deleting text before zero-width textprop removes it
Bram Moolenaar <Bram@vim.org>
parents: 18605
diff changeset
1062 " 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
1063 normal! 0xxxx
25392
b427a26b0210 patch 8.2.3233: prop_list() and prop_find() do not indicate the buffer
Bram Moolenaar <Bram@vim.org>
parents: 25198
diff changeset
1064 let expected = [#{type_bufnr: 0, col: 1, length: 0, id: 0, type: 'comment', start: 1, end: 1} ]
18631
e2d9f4d030fa patch 8.1.2308: deleting text before zero-width textprop removes it
Bram Moolenaar <Bram@vim.org>
parents: 18605
diff changeset
1065 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
1066
e2d9f4d030fa patch 8.1.2308: deleting text before zero-width textprop removes it
Bram Moolenaar <Bram@vim.org>
parents: 18605
diff changeset
1067 bwipe!
e2d9f4d030fa patch 8.1.2308: deleting text before zero-width textprop removes it
Bram Moolenaar <Bram@vim.org>
parents: 18605
diff changeset
1068 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
1069 endfunc
e2d9f4d030fa patch 8.1.2308: deleting text before zero-width textprop removes it
Bram Moolenaar <Bram@vim.org>
parents: 18605
diff changeset
1070
15314
c4d62945d96f patch 8.1.0665: text property display wrong when 'spell' is set
Bram Moolenaar <Bram@vim.org>
parents: 15294
diff changeset
1071 " 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
1072 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
1073 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
1074 " 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
1075 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
1076 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
1077 endif
c4d62945d96f patch 8.1.0665: text property display wrong when 'spell' is set
Bram Moolenaar <Bram@vim.org>
parents: 15294
diff changeset
1078 call writefile([
16545
7a563ee902b6 patch 8.1.1276: cannot combine text properties with syntax highlighting
Bram Moolenaar <Bram@vim.org>
parents: 16060
diff changeset
1079 \ "call setline(1, ["
7a563ee902b6 patch 8.1.1276: cannot combine text properties with syntax highlighting
Bram Moolenaar <Bram@vim.org>
parents: 16060
diff changeset
1080 \ .. "'One two',"
7a563ee902b6 patch 8.1.1276: cannot combine text properties with syntax highlighting
Bram Moolenaar <Bram@vim.org>
parents: 16060
diff changeset
1081 \ .. "'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
1082 \ .. "'--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
1083 \ .. "'// 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
1084 \ .. "'first line',"
6f453673eb19 patch 8.1.1341: text properties are lost when joining lines
Bram Moolenaar <Bram@vim.org>
parents: 16676
diff changeset
1085 \ .. "' second line ',"
6f453673eb19 patch 8.1.1341: text properties are lost when joining lines
Bram Moolenaar <Bram@vim.org>
parents: 16676
diff changeset
1086 \ .. "'third line',"
6f453673eb19 patch 8.1.1341: text properties are lost when joining lines
Bram Moolenaar <Bram@vim.org>
parents: 16676
diff changeset
1087 \ .. "' fourth line',"
16545
7a563ee902b6 patch 8.1.1276: cannot combine text properties with syntax highlighting
Bram Moolenaar <Bram@vim.org>
parents: 16060
diff changeset
1088 \ .. "])",
15314
c4d62945d96f patch 8.1.0665: text property display wrong when 'spell' is set
Bram Moolenaar <Bram@vim.org>
parents: 15294
diff changeset
1089 \ "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
1090 \ "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
1091 \ "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
1092 \ "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
1093 \ "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
1094 \ "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
1095 \ "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
1096 \ "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
1097 \ "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
1098 \ "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
1099 \ "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
1100 \ "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
1101 \ "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
1102 \ "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
1103 \ "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
1104 \ "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
1105 \ "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
1106 \ "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
1107 \ "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
1108 \ "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
1109 \ "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
1110 \ "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
1111 \ "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
1112 \ "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
1113 \ "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
1114 \ "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
1115 \ "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
1116 \ "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
1117 \ "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
1118 \ "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
1119 \ "set spell",
16545
7a563ee902b6 patch 8.1.1276: cannot combine text properties with syntax highlighting
Bram Moolenaar <Bram@vim.org>
parents: 16060
diff changeset
1120 \ "syn match Comment '//.*'",
7a563ee902b6 patch 8.1.1276: cannot combine text properties with syntax highlighting
Bram Moolenaar <Bram@vim.org>
parents: 16060
diff changeset
1121 \ "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
1122 \ "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
1123 \ "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
1124 \ "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
1125 \ "normal 3J",
6f453673eb19 patch 8.1.1341: text properties are lost when joining lines
Bram Moolenaar <Bram@vim.org>
parents: 16676
diff changeset
1126 \ "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
1127 \], 'XtestProp')
16678
6f453673eb19 patch 8.1.1341: text properties are lost when joining lines
Bram Moolenaar <Bram@vim.org>
parents: 16676
diff changeset
1128 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
1129 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
1130
15314
c4d62945d96f patch 8.1.0665: text property display wrong when 'spell' is set
Bram Moolenaar <Bram@vim.org>
parents: 15294
diff changeset
1131 " clean up
c4d62945d96f patch 8.1.0665: text property display wrong when 'spell' is set
Bram Moolenaar <Bram@vim.org>
parents: 15294
diff changeset
1132 call StopVimInTerminal(buf)
15318
f58e7895cb40 patch 8.1.0667: textprop test leaves file behind
Bram Moolenaar <Bram@vim.org>
parents: 15314
diff changeset
1133 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
1134 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
1135
7847d281cbbf patch 8.1.1343: text properties not adjusted for Visual block mode delete
Bram Moolenaar <Bram@vim.org>
parents: 16678
diff changeset
1136 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
1137 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
1138 \ "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
1139 \ .. "'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
1140 \ .. "'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
1141 \ .. "'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
1142 \ .. "'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
1143 \ .. "'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
1144 \ .. "'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
1145 \ .. "'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
1146 \ .. "'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
1147 \ .. "'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
1148 \ .. "' 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
1149 \ .. "])",
7847d281cbbf patch 8.1.1343: text properties not adjusted for Visual block mode delete
Bram Moolenaar <Bram@vim.org>
parents: 16678
diff changeset
1150 \ "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
1151 \ "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
1152 \ "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
1153 \ "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
1154 \ "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
1155 \ "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
1156 \ "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
1157 \ "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
1158 \ "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
1159 \ "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
1160 \ "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
1161 \ "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
1162 \ "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
1163 \], 'XtestPropVis')
7847d281cbbf patch 8.1.1343: text properties not adjusted for Visual block mode delete
Bram Moolenaar <Bram@vim.org>
parents: 16678
diff changeset
1164 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
1165 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
1166
7847d281cbbf patch 8.1.1343: text properties not adjusted for Visual block mode delete
Bram Moolenaar <Bram@vim.org>
parents: 16678
diff changeset
1167 " 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
1168 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
1169 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
1170 endfunc
7847d281cbbf patch 8.1.1343: text properties not adjusted for Visual block mode delete
Bram Moolenaar <Bram@vim.org>
parents: 16678
diff changeset
1171
7847d281cbbf patch 8.1.1343: text properties not adjusted for Visual block mode delete
Bram Moolenaar <Bram@vim.org>
parents: 16678
diff changeset
1172 " 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
1173 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
1174 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
1175
7847d281cbbf patch 8.1.1343: text properties not adjusted for Visual block mode delete
Bram Moolenaar <Bram@vim.org>
parents: 16678
diff changeset
1176 " 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
1177 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
1178
7847d281cbbf patch 8.1.1343: text properties not adjusted for Visual block mode delete
Bram Moolenaar <Bram@vim.org>
parents: 16678
diff changeset
1179 " 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
1180 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
1181 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
1182
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
1183 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
1184 CheckScreendump
17147
a001a0d88d42 patch 8.1.1573: textprop test fails if screenhots do not work
Bram Moolenaar <Bram@vim.org>
parents: 17143
diff changeset
1185
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
1186 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
1187 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
1188 \ "\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
1189 \ "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
1190 \ ])
ee090ecd70f6 patch 8.1.1571: textprop highlight starts too early if just after a tab
Bram Moolenaar <Bram@vim.org>
parents: 17089
diff changeset
1191 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
1192 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
1193 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
1194 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
1195 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
1196 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
1197 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
1198 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
1199
ee090ecd70f6 patch 8.1.1571: textprop highlight starts too early if just after a tab
Bram Moolenaar <Bram@vim.org>
parents: 17089
diff changeset
1200 " 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
1201 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
1202 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
1203 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
1204
23901
6793853063e5 patch 8.2.2493: text property for text left of window shows up
Bram Moolenaar <Bram@vim.org>
parents: 23776
diff changeset
1205 func Test_textprop_nowrap_scrolled()
6793853063e5 patch 8.2.2493: text property for text left of window shows up
Bram Moolenaar <Bram@vim.org>
parents: 23776
diff changeset
1206 CheckScreendump
6793853063e5 patch 8.2.2493: text property for text left of window shows up
Bram Moolenaar <Bram@vim.org>
parents: 23776
diff changeset
1207
6793853063e5 patch 8.2.2493: text property for text left of window shows up
Bram Moolenaar <Bram@vim.org>
parents: 23776
diff changeset
1208 let lines =<< trim END
6793853063e5 patch 8.2.2493: text property for text left of window shows up
Bram Moolenaar <Bram@vim.org>
parents: 23776
diff changeset
1209 vim9script
6793853063e5 patch 8.2.2493: text property for text left of window shows up
Bram Moolenaar <Bram@vim.org>
parents: 23776
diff changeset
1210 set nowrap
6793853063e5 patch 8.2.2493: text property for text left of window shows up
Bram Moolenaar <Bram@vim.org>
parents: 23776
diff changeset
1211 setline(1, 'The number 123 is smaller than 4567.' .. repeat('X', &columns))
6793853063e5 patch 8.2.2493: text property for text left of window shows up
Bram Moolenaar <Bram@vim.org>
parents: 23776
diff changeset
1212 prop_type_add('number', {'highlight': 'ErrorMsg'})
6793853063e5 patch 8.2.2493: text property for text left of window shows up
Bram Moolenaar <Bram@vim.org>
parents: 23776
diff changeset
1213 prop_add(1, 12, {'length': 3, 'type': 'number'})
6793853063e5 patch 8.2.2493: text property for text left of window shows up
Bram Moolenaar <Bram@vim.org>
parents: 23776
diff changeset
1214 prop_add(1, 32, {'length': 4, 'type': 'number'})
6793853063e5 patch 8.2.2493: text property for text left of window shows up
Bram Moolenaar <Bram@vim.org>
parents: 23776
diff changeset
1215 feedkeys('gg20zl', 'nxt')
6793853063e5 patch 8.2.2493: text property for text left of window shows up
Bram Moolenaar <Bram@vim.org>
parents: 23776
diff changeset
1216 END
6793853063e5 patch 8.2.2493: text property for text left of window shows up
Bram Moolenaar <Bram@vim.org>
parents: 23776
diff changeset
1217 call writefile(lines, 'XtestNowrap')
6793853063e5 patch 8.2.2493: text property for text left of window shows up
Bram Moolenaar <Bram@vim.org>
parents: 23776
diff changeset
1218 let buf = RunVimInTerminal('-S XtestNowrap', {'rows': 6})
6793853063e5 patch 8.2.2493: text property for text left of window shows up
Bram Moolenaar <Bram@vim.org>
parents: 23776
diff changeset
1219 call VerifyScreenDump(buf, 'Test_textprop_nowrap_01', {})
6793853063e5 patch 8.2.2493: text property for text left of window shows up
Bram Moolenaar <Bram@vim.org>
parents: 23776
diff changeset
1220
6793853063e5 patch 8.2.2493: text property for text left of window shows up
Bram Moolenaar <Bram@vim.org>
parents: 23776
diff changeset
1221 call term_sendkeys(buf, "$")
6793853063e5 patch 8.2.2493: text property for text left of window shows up
Bram Moolenaar <Bram@vim.org>
parents: 23776
diff changeset
1222 call VerifyScreenDump(buf, 'Test_textprop_nowrap_02', {})
6793853063e5 patch 8.2.2493: text property for text left of window shows up
Bram Moolenaar <Bram@vim.org>
parents: 23776
diff changeset
1223
6793853063e5 patch 8.2.2493: text property for text left of window shows up
Bram Moolenaar <Bram@vim.org>
parents: 23776
diff changeset
1224 " clean up
6793853063e5 patch 8.2.2493: text property for text left of window shows up
Bram Moolenaar <Bram@vim.org>
parents: 23776
diff changeset
1225 call StopVimInTerminal(buf)
6793853063e5 patch 8.2.2493: text property for text left of window shows up
Bram Moolenaar <Bram@vim.org>
parents: 23776
diff changeset
1226 call delete('XtestNowrap')
6793853063e5 patch 8.2.2493: text property for text left of window shows up
Bram Moolenaar <Bram@vim.org>
parents: 23776
diff changeset
1227 endfunc
6793853063e5 patch 8.2.2493: text property for text left of window shows up
Bram Moolenaar <Bram@vim.org>
parents: 23776
diff changeset
1228
18317
d2228d4cf1f6 patch 8.1.2153: combining text property and syntax highlight is wrong
Bram Moolenaar <Bram@vim.org>
parents: 17980
diff changeset
1229 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
1230 CheckScreendump
d2228d4cf1f6 patch 8.1.2153: combining text property and syntax highlight is wrong
Bram Moolenaar <Bram@vim.org>
parents: 17980
diff changeset
1231
d2228d4cf1f6 patch 8.1.2153: combining text property and syntax highlight is wrong
Bram Moolenaar <Bram@vim.org>
parents: 17980
diff changeset
1232 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
1233 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
1234 \ "(abc)",
d2228d4cf1f6 patch 8.1.2153: combining text property and syntax highlight is wrong
Bram Moolenaar <Bram@vim.org>
parents: 17980
diff changeset
1235 \ ])
d2228d4cf1f6 patch 8.1.2153: combining text property and syntax highlight is wrong
Bram Moolenaar <Bram@vim.org>
parents: 17980
diff changeset
1236 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
1237 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
1238
d2228d4cf1f6 patch 8.1.2153: combining text property and syntax highlight is wrong
Bram Moolenaar <Bram@vim.org>
parents: 17980
diff changeset
1239 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
1240 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
1241 END
d2228d4cf1f6 patch 8.1.2153: combining text property and syntax highlight is wrong
Bram Moolenaar <Bram@vim.org>
parents: 17980
diff changeset
1242 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
1243 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
1244 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
1245
d2228d4cf1f6 patch 8.1.2153: combining text property and syntax highlight is wrong
Bram Moolenaar <Bram@vim.org>
parents: 17980
diff changeset
1246 " clean up
d2228d4cf1f6 patch 8.1.2153: combining text property and syntax highlight is wrong
Bram Moolenaar <Bram@vim.org>
parents: 17980
diff changeset
1247 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
1248 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
1249 endfunc
d2228d4cf1f6 patch 8.1.2153: combining text property and syntax highlight is wrong
Bram Moolenaar <Bram@vim.org>
parents: 17980
diff changeset
1250
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
1251 " 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
1252 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
1253 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
1254 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
1255 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
1256 close
16786
98ca522e6453 patch 8.1.1395: saving for undo may access invalid memory
Bram Moolenaar <Bram@vim.org>
parents: 16772
diff changeset
1257 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
1258 endfunc
98ca522e6453 patch 8.1.1395: saving for undo may access invalid memory
Bram Moolenaar <Bram@vim.org>
parents: 16772
diff changeset
1259
17208
13d0753511fe patch 8.1.1603: crash when using unknown highlighting in text property
Bram Moolenaar <Bram@vim.org>
parents: 17147
diff changeset
1260 " 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
1261 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
1262 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
1263 new
13d0753511fe patch 8.1.1603: crash when using unknown highlighting in text property
Bram Moolenaar <Bram@vim.org>
parents: 17147
diff changeset
1264 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
1265 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
1266 redraw
13d0753511fe patch 8.1.1603: crash when using unknown highlighting in text property
Bram Moolenaar <Bram@vim.org>
parents: 17147
diff changeset
1267 bwipe!
13d0753511fe patch 8.1.1603: crash when using unknown highlighting in text property
Bram Moolenaar <Bram@vim.org>
parents: 17147
diff changeset
1268 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
1269 endfunc
13d0753511fe patch 8.1.1603: crash when using unknown highlighting in text property
Bram Moolenaar <Bram@vim.org>
parents: 17147
diff changeset
1270
16786
98ca522e6453 patch 8.1.1395: saving for undo may access invalid memory
Bram Moolenaar <Bram@vim.org>
parents: 16772
diff changeset
1271 " 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
1272 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
1273 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
1274 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
1275 next X
98ca522e6453 patch 8.1.1395: saving for undo may access invalid memory
Bram Moolenaar <Bram@vim.org>
parents: 16772
diff changeset
1276 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
1277 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
1278
18093a6accb5 patch 8.1.1388: errors when calling prop_remove() for an unloaded buffer
Bram Moolenaar <Bram@vim.org>
parents: 16770
diff changeset
1279 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
1280 new
18093a6accb5 patch 8.1.1388: errors when calling prop_remove() for an unloaded buffer
Bram Moolenaar <Bram@vim.org>
parents: 16770
diff changeset
1281 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
1282 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
1283 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
1284 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
1285 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
1286 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
1287 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
1288 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
1289 close
18093a6accb5 patch 8.1.1388: errors when calling prop_remove() for an unloaded buffer
Bram Moolenaar <Bram@vim.org>
parents: 16770
diff changeset
1290 endfunc
17694
6f9cde96ee3c patch 8.1.1844: buffer no longer unloaded when adding text properties
Bram Moolenaar <Bram@vim.org>
parents: 17208
diff changeset
1291
6f9cde96ee3c patch 8.1.1844: buffer no longer unloaded when adding text properties
Bram Moolenaar <Bram@vim.org>
parents: 17208
diff changeset
1292 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
1293 edit Xaaa
6f9cde96ee3c patch 8.1.1844: buffer no longer unloaded when adding text properties
Bram Moolenaar <Bram@vim.org>
parents: 17208
diff changeset
1294 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
1295 write
6f9cde96ee3c patch 8.1.1844: buffer no longer unloaded when adding text properties
Bram Moolenaar <Bram@vim.org>
parents: 17208
diff changeset
1296 edit Xbbb
6f9cde96ee3c patch 8.1.1844: buffer no longer unloaded when adding text properties
Bram Moolenaar <Bram@vim.org>
parents: 17208
diff changeset
1297 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
1298 write
6f9cde96ee3c patch 8.1.1844: buffer no longer unloaded when adding text properties
Bram Moolenaar <Bram@vim.org>
parents: 17208
diff changeset
1299 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
1300 edit Xaaa
6f9cde96ee3c patch 8.1.1844: buffer no longer unloaded when adding text properties
Bram Moolenaar <Bram@vim.org>
parents: 17208
diff changeset
1301
6f9cde96ee3c patch 8.1.1844: buffer no longer unloaded when adding text properties
Bram Moolenaar <Bram@vim.org>
parents: 17208
diff changeset
1302 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
1303 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
1304 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
1305 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
1306 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
1307
6f9cde96ee3c patch 8.1.1844: buffer no longer unloaded when adding text properties
Bram Moolenaar <Bram@vim.org>
parents: 17208
diff changeset
1308 bwipe! Xaaa
6f9cde96ee3c patch 8.1.1844: buffer no longer unloaded when adding text properties
Bram Moolenaar <Bram@vim.org>
parents: 17208
diff changeset
1309 bwipe! Xbbb
6f9cde96ee3c patch 8.1.1844: buffer no longer unloaded when adding text properties
Bram Moolenaar <Bram@vim.org>
parents: 17208
diff changeset
1310 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
1311 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
1312 endfunc
18444
967ca19425e3 patch 8.1.2216: text property in wrong place after :substitute
Bram Moolenaar <Bram@vim.org>
parents: 18317
diff changeset
1313
967ca19425e3 patch 8.1.2216: text property in wrong place after :substitute
Bram Moolenaar <Bram@vim.org>
parents: 18317
diff changeset
1314 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
1315 new
967ca19425e3 patch 8.1.2216: text property in wrong place after :substitute
Bram Moolenaar <Bram@vim.org>
parents: 18317
diff changeset
1316 " text_prop.vim
967ca19425e3 patch 8.1.2216: text property in wrong place after :substitute
Bram Moolenaar <Bram@vim.org>
parents: 18317
diff changeset
1317 call setline(1, [
967ca19425e3 patch 8.1.2216: text property in wrong place after :substitute
Bram Moolenaar <Bram@vim.org>
parents: 18317
diff changeset
1318 \ '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
1319 \ '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
1320 \ '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
1321
967ca19425e3 patch 8.1.2216: text property in wrong place after :substitute
Bram Moolenaar <Bram@vim.org>
parents: 18317
diff changeset
1322 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
1323
967ca19425e3 patch 8.1.2216: text property in wrong place after :substitute
Bram Moolenaar <Bram@vim.org>
parents: 18317
diff changeset
1324 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
1325 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
1326 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
1327 set ul&
25392
b427a26b0210 patch 8.2.3233: prop_list() and prop_find() do not indicate the buffer
Bram Moolenaar <Bram@vim.org>
parents: 25198
diff changeset
1328 let expected = [
b427a26b0210 patch 8.2.3233: prop_list() and prop_find() do not indicate the buffer
Bram Moolenaar <Bram@vim.org>
parents: 25198
diff changeset
1329 \ #{type_bufnr: 0, id: 0, col: 13, end: 1, type: 'number', length: 3, start: 1},
b427a26b0210 patch 8.2.3233: prop_list() and prop_find() do not indicate the buffer
Bram Moolenaar <Bram@vim.org>
parents: 25198
diff changeset
1330 \ #{type_bufnr: 0, id: 0, col: 1, end: 1, type: 'number', length: 3, start: 1},
b427a26b0210 patch 8.2.3233: prop_list() and prop_find() do not indicate the buffer
Bram Moolenaar <Bram@vim.org>
parents: 25198
diff changeset
1331 \ #{type_bufnr: 0, id: 0, col: 50, end: 1, type: 'number', length: 4, start: 1}]
b427a26b0210 patch 8.2.3233: prop_list() and prop_find() do not indicate the buffer
Bram Moolenaar <Bram@vim.org>
parents: 25198
diff changeset
1332
b427a26b0210 patch 8.2.3233: prop_list() and prop_find() do not indicate the buffer
Bram Moolenaar <Bram@vim.org>
parents: 25198
diff changeset
1333 " TODO
b427a26b0210 patch 8.2.3233: prop_list() and prop_find() do not indicate the buffer
Bram Moolenaar <Bram@vim.org>
parents: 25198
diff changeset
1334 return
18444
967ca19425e3 patch 8.1.2216: text property in wrong place after :substitute
Bram Moolenaar <Bram@vim.org>
parents: 18317
diff changeset
1335 " 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
1336 %s/\s\+/ /g
25392
b427a26b0210 patch 8.2.3233: prop_list() and prop_find() do not indicate the buffer
Bram Moolenaar <Bram@vim.org>
parents: 25198
diff changeset
1337 call assert_equal(expected, prop_list(1) + prop_list(2) + prop_list(3))
18444
967ca19425e3 patch 8.1.2216: text property in wrong place after :substitute
Bram Moolenaar <Bram@vim.org>
parents: 18317
diff changeset
1338
967ca19425e3 patch 8.1.2216: text property in wrong place after :substitute
Bram Moolenaar <Bram@vim.org>
parents: 18317
diff changeset
1339 " remove some text
967ca19425e3 patch 8.1.2216: text property in wrong place after :substitute
Bram Moolenaar <Bram@vim.org>
parents: 18317
diff changeset
1340 :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
1341 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
1342 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
1343 bwipe!
967ca19425e3 patch 8.1.2216: text property in wrong place after :substitute
Bram Moolenaar <Bram@vim.org>
parents: 18317
diff changeset
1344 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
1345
22331
0271c2b8bb35 patch 8.2.1714: text properties corrupted with substitute command
Bram Moolenaar <Bram@vim.org>
parents: 22282
diff changeset
1346 " This was causing property corruption.
0271c2b8bb35 patch 8.2.1714: text properties corrupted with substitute command
Bram Moolenaar <Bram@vim.org>
parents: 22282
diff changeset
1347 func Test_proptype_substitute3()
0271c2b8bb35 patch 8.2.1714: text properties corrupted with substitute command
Bram Moolenaar <Bram@vim.org>
parents: 22282
diff changeset
1348 new
0271c2b8bb35 patch 8.2.1714: text properties corrupted with substitute command
Bram Moolenaar <Bram@vim.org>
parents: 22282
diff changeset
1349 call setline(1, ['abcxxx', 'def'])
0271c2b8bb35 patch 8.2.1714: text properties corrupted with substitute command
Bram Moolenaar <Bram@vim.org>
parents: 22282
diff changeset
1350 call prop_type_add("test", {"highlight": "Search"})
0271c2b8bb35 patch 8.2.1714: text properties corrupted with substitute command
Bram Moolenaar <Bram@vim.org>
parents: 22282
diff changeset
1351 call prop_add(1, 2, {"end_lnum": 2, "end_col": 2, "type": "test"})
0271c2b8bb35 patch 8.2.1714: text properties corrupted with substitute command
Bram Moolenaar <Bram@vim.org>
parents: 22282
diff changeset
1352 %s/x\+$//
0271c2b8bb35 patch 8.2.1714: text properties corrupted with substitute command
Bram Moolenaar <Bram@vim.org>
parents: 22282
diff changeset
1353 redraw
0271c2b8bb35 patch 8.2.1714: text properties corrupted with substitute command
Bram Moolenaar <Bram@vim.org>
parents: 22282
diff changeset
1354
0271c2b8bb35 patch 8.2.1714: text properties corrupted with substitute command
Bram Moolenaar <Bram@vim.org>
parents: 22282
diff changeset
1355 call prop_type_delete('test')
0271c2b8bb35 patch 8.2.1714: text properties corrupted with substitute command
Bram Moolenaar <Bram@vim.org>
parents: 22282
diff changeset
1356 bwipe!
0271c2b8bb35 patch 8.2.1714: text properties corrupted with substitute command
Bram Moolenaar <Bram@vim.org>
parents: 22282
diff changeset
1357 endfunc
0271c2b8bb35 patch 8.2.1714: text properties corrupted with substitute command
Bram Moolenaar <Bram@vim.org>
parents: 22282
diff changeset
1358
19097
bcbc9fe665b5 patch 8.2.0109: corrupted text properties when expanding spaces
Bram Moolenaar <Bram@vim.org>
parents: 19045
diff changeset
1359 func SaveOptions()
bcbc9fe665b5 patch 8.2.0109: corrupted text properties when expanding spaces
Bram Moolenaar <Bram@vim.org>
parents: 19045
diff changeset
1360 let d = #{tabstop: &tabstop,
bcbc9fe665b5 patch 8.2.0109: corrupted text properties when expanding spaces
Bram Moolenaar <Bram@vim.org>
parents: 19045
diff changeset
1361 \ softtabstop: &softtabstop,
bcbc9fe665b5 patch 8.2.0109: corrupted text properties when expanding spaces
Bram Moolenaar <Bram@vim.org>
parents: 19045
diff changeset
1362 \ shiftwidth: &shiftwidth,
bcbc9fe665b5 patch 8.2.0109: corrupted text properties when expanding spaces
Bram Moolenaar <Bram@vim.org>
parents: 19045
diff changeset
1363 \ expandtab: &expandtab,
bcbc9fe665b5 patch 8.2.0109: corrupted text properties when expanding spaces
Bram Moolenaar <Bram@vim.org>
parents: 19045
diff changeset
1364 \ foldmethod: '"' .. &foldmethod .. '"',
bcbc9fe665b5 patch 8.2.0109: corrupted text properties when expanding spaces
Bram Moolenaar <Bram@vim.org>
parents: 19045
diff changeset
1365 \ }
bcbc9fe665b5 patch 8.2.0109: corrupted text properties when expanding spaces
Bram Moolenaar <Bram@vim.org>
parents: 19045
diff changeset
1366 return d
bcbc9fe665b5 patch 8.2.0109: corrupted text properties when expanding spaces
Bram Moolenaar <Bram@vim.org>
parents: 19045
diff changeset
1367 endfunc
bcbc9fe665b5 patch 8.2.0109: corrupted text properties when expanding spaces
Bram Moolenaar <Bram@vim.org>
parents: 19045
diff changeset
1368
bcbc9fe665b5 patch 8.2.0109: corrupted text properties when expanding spaces
Bram Moolenaar <Bram@vim.org>
parents: 19045
diff changeset
1369 func RestoreOptions(dict)
bcbc9fe665b5 patch 8.2.0109: corrupted text properties when expanding spaces
Bram Moolenaar <Bram@vim.org>
parents: 19045
diff changeset
1370 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
1371 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
1372 endfor
bcbc9fe665b5 patch 8.2.0109: corrupted text properties when expanding spaces
Bram Moolenaar <Bram@vim.org>
parents: 19045
diff changeset
1373 endfunc
bcbc9fe665b5 patch 8.2.0109: corrupted text properties when expanding spaces
Bram Moolenaar <Bram@vim.org>
parents: 19045
diff changeset
1374
19045
143d44d8f477 patch 8.2.0083: text properties wrong when tabs and spaces are exchanged
Bram Moolenaar <Bram@vim.org>
parents: 18631
diff changeset
1375 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
1376 new
19097
bcbc9fe665b5 patch 8.2.0109: corrupted text properties when expanding spaces
Bram Moolenaar <Bram@vim.org>
parents: 19045
diff changeset
1377 let save_dict = SaveOptions()
bcbc9fe665b5 patch 8.2.0109: corrupted text properties when expanding spaces
Bram Moolenaar <Bram@vim.org>
parents: 19045
diff changeset
1378
19045
143d44d8f477 patch 8.2.0083: text properties wrong when tabs and spaces are exchanged
Bram Moolenaar <Bram@vim.org>
parents: 18631
diff changeset
1379 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
1380 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
1381 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
1382 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
1383 set foldmethod=marker
19097
bcbc9fe665b5 patch 8.2.0109: corrupted text properties when expanding spaces
Bram Moolenaar <Bram@vim.org>
parents: 19045
diff changeset
1384
19045
143d44d8f477 patch 8.2.0083: text properties wrong when tabs and spaces are exchanged
Bram Moolenaar <Bram@vim.org>
parents: 18631
diff changeset
1385 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
1386 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
1387 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
1388 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
1389 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
1390 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
1391 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
1392 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
1393 try
143d44d8f477 patch 8.2.0083: text properties wrong when tabs and spaces are exchanged
Bram Moolenaar <Bram@vim.org>
parents: 18631
diff changeset
1394 " 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
1395 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
1396 " 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
1397 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
1398 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
1399 endtry
143d44d8f477 patch 8.2.0083: text properties wrong when tabs and spaces are exchanged
Bram Moolenaar <Bram@vim.org>
parents: 18631
diff changeset
1400 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
1401 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
1402
bcbc9fe665b5 patch 8.2.0109: corrupted text properties when expanding spaces
Bram Moolenaar <Bram@vim.org>
parents: 19045
diff changeset
1403 call RestoreOptions(save_dict)
bcbc9fe665b5 patch 8.2.0109: corrupted text properties when expanding spaces
Bram Moolenaar <Bram@vim.org>
parents: 19045
diff changeset
1404 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
1405 endfunc
19097
bcbc9fe665b5 patch 8.2.0109: corrupted text properties when expanding spaces
Bram Moolenaar <Bram@vim.org>
parents: 19045
diff changeset
1406
bcbc9fe665b5 patch 8.2.0109: corrupted text properties when expanding spaces
Bram Moolenaar <Bram@vim.org>
parents: 19045
diff changeset
1407 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
1408 new
bcbc9fe665b5 patch 8.2.0109: corrupted text properties when expanding spaces
Bram Moolenaar <Bram@vim.org>
parents: 19045
diff changeset
1409 let save_dict = SaveOptions()
bcbc9fe665b5 patch 8.2.0109: corrupted text properties when expanding spaces
Bram Moolenaar <Bram@vim.org>
parents: 19045
diff changeset
1410
bcbc9fe665b5 patch 8.2.0109: corrupted text properties when expanding spaces
Bram Moolenaar <Bram@vim.org>
parents: 19045
diff changeset
1411 set tabstop=8
bcbc9fe665b5 patch 8.2.0109: corrupted text properties when expanding spaces
Bram Moolenaar <Bram@vim.org>
parents: 19045
diff changeset
1412 set softtabstop=4
bcbc9fe665b5 patch 8.2.0109: corrupted text properties when expanding spaces
Bram Moolenaar <Bram@vim.org>
parents: 19045
diff changeset
1413 set shiftwidth=4
bcbc9fe665b5 patch 8.2.0109: corrupted text properties when expanding spaces
Bram Moolenaar <Bram@vim.org>
parents: 19045
diff changeset
1414 set noexpandtab
bcbc9fe665b5 patch 8.2.0109: corrupted text properties when expanding spaces
Bram Moolenaar <Bram@vim.org>
parents: 19045
diff changeset
1415 set foldmethod=marker
bcbc9fe665b5 patch 8.2.0109: corrupted text properties when expanding spaces
Bram Moolenaar <Bram@vim.org>
parents: 19045
diff changeset
1416
bcbc9fe665b5 patch 8.2.0109: corrupted text properties when expanding spaces
Bram Moolenaar <Bram@vim.org>
parents: 19045
diff changeset
1417 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
1418 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
1419 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
1420 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
1421 " 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
1422 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
1423 redraw
bcbc9fe665b5 patch 8.2.0109: corrupted text properties when expanding spaces
Bram Moolenaar <Bram@vim.org>
parents: 19045
diff changeset
1424 " 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
1425 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
1426 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
1427 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
1428 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
1429
bcbc9fe665b5 patch 8.2.0109: corrupted text properties when expanding spaces
Bram Moolenaar <Bram@vim.org>
parents: 19045
diff changeset
1430 call RestoreOptions(save_dict)
bcbc9fe665b5 patch 8.2.0109: corrupted text properties when expanding spaces
Bram Moolenaar <Bram@vim.org>
parents: 19045
diff changeset
1431 bwipe!
bcbc9fe665b5 patch 8.2.0109: corrupted text properties when expanding spaces
Bram Moolenaar <Bram@vim.org>
parents: 19045
diff changeset
1432 endfunc
bcbc9fe665b5 patch 8.2.0109: corrupted text properties when expanding spaces
Bram Moolenaar <Bram@vim.org>
parents: 19045
diff changeset
1433
bcbc9fe665b5 patch 8.2.0109: corrupted text properties when expanding spaces
Bram Moolenaar <Bram@vim.org>
parents: 19045
diff changeset
1434 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
1435 new
bcbc9fe665b5 patch 8.2.0109: corrupted text properties when expanding spaces
Bram Moolenaar <Bram@vim.org>
parents: 19045
diff changeset
1436 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
1437 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
1438 call prop_add(1, 1, {'end_col': 2, 'type': 'test'})
25392
b427a26b0210 patch 8.2.3233: prop_list() and prop_find() do not indicate the buffer
Bram Moolenaar <Bram@vim.org>
parents: 25198
diff changeset
1439 call assert_equal([#{type_bufnr: 0, id: 0, col: 1, end: 1, type: 'test', length: 1, start: 1}], prop_list(1))
19097
bcbc9fe665b5 patch 8.2.0109: corrupted text properties when expanding spaces
Bram Moolenaar <Bram@vim.org>
parents: 19045
diff changeset
1440
bcbc9fe665b5 patch 8.2.0109: corrupted text properties when expanding spaces
Bram Moolenaar <Bram@vim.org>
parents: 19045
diff changeset
1441 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
1442 call assert_equal('just s<F8>ome text', getline(1))
25392
b427a26b0210 patch 8.2.3233: prop_list() and prop_find() do not indicate the buffer
Bram Moolenaar <Bram@vim.org>
parents: 25198
diff changeset
1443 call assert_equal([#{type_bufnr: 0, id: 0, col: 1, end: 1, type: 'test', length: 1, start: 1}], prop_list(1))
19097
bcbc9fe665b5 patch 8.2.0109: corrupted text properties when expanding spaces
Bram Moolenaar <Bram@vim.org>
parents: 19045
diff changeset
1444
bcbc9fe665b5 patch 8.2.0109: corrupted text properties when expanding spaces
Bram Moolenaar <Bram@vim.org>
parents: 19045
diff changeset
1445 bwipe!
bcbc9fe665b5 patch 8.2.0109: corrupted text properties when expanding spaces
Bram Moolenaar <Bram@vim.org>
parents: 19045
diff changeset
1446 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
1447 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
1448 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
1449
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
1450 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
1451 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
1452 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
1453 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
1454 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
1455 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
1456
25392
b427a26b0210 patch 8.2.3233: prop_list() and prop_find() do not indicate the buffer
Bram Moolenaar <Bram@vim.org>
parents: 25198
diff changeset
1457 call assert_equal(
b427a26b0210 patch 8.2.3233: prop_list() and prop_find() do not indicate the buffer
Bram Moolenaar <Bram@vim.org>
parents: 25198
diff changeset
1458 \ #{type_bufnr: 0, id: 0, lnum: 1, col: 10, end: 1, type: 'test', length: 3, start: 1},
b427a26b0210 patch 8.2.3233: prop_list() and prop_find() do not indicate the buffer
Bram Moolenaar <Bram@vim.org>
parents: 25198
diff changeset
1459 \ prop_find(#{type: 'test', lnum: 1, col: 6}))
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
1460
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
1461 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
1462 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
1463 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
1464
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
1465 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
1466 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
1467 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
1468 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
1469 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
1470
25392
b427a26b0210 patch 8.2.3233: prop_list() and prop_find() do not indicate the buffer
Bram Moolenaar <Bram@vim.org>
parents: 25198
diff changeset
1471 call assert_equal(
b427a26b0210 patch 8.2.3233: prop_list() and prop_find() do not indicate the buffer
Bram Moolenaar <Bram@vim.org>
parents: 25198
diff changeset
1472 \ #{type_bufnr: 0, id: 0, lnum: 1, col: 1, end: 1, type: 'test', length: 0, start: 1},
b427a26b0210 patch 8.2.3233: prop_list() and prop_find() do not indicate the buffer
Bram Moolenaar <Bram@vim.org>
parents: 25198
diff changeset
1473 \ prop_find(#{type: 'test', lnum: 1}))
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
1474
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
1475 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
1476 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
1477 endfunc
20178
2fb397573541 patch 8.2.0644: insufficient testing for invalid function arguments
Bram Moolenaar <Bram@vim.org>
parents: 19642
diff changeset
1478
2fb397573541 patch 8.2.0644: insufficient testing for invalid function arguments
Bram Moolenaar <Bram@vim.org>
parents: 19642
diff changeset
1479 " Test for passing invalid arguments to prop_xxx() functions
2fb397573541 patch 8.2.0644: insufficient testing for invalid function arguments
Bram Moolenaar <Bram@vim.org>
parents: 19642
diff changeset
1480 func Test_prop_func_invalid_args()
2fb397573541 patch 8.2.0644: insufficient testing for invalid function arguments
Bram Moolenaar <Bram@vim.org>
parents: 19642
diff changeset
1481 call assert_fails('call prop_clear(1, 2, [])', 'E715:')
2fb397573541 patch 8.2.0644: insufficient testing for invalid function arguments
Bram Moolenaar <Bram@vim.org>
parents: 19642
diff changeset
1482 call assert_fails('call prop_clear(-1, 2)', 'E16:')
25198
eafc0e07b188 patch 8.2.3135: Vim9: builtin function arguments not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25050
diff changeset
1483 call assert_fails('call prop_find(test_null_dict())', 'E715:')
21265
6a4806e326dd patch 8.2.1183: assert_fails() checks the last error message
Bram Moolenaar <Bram@vim.org>
parents: 20583
diff changeset
1484 call assert_fails('call prop_find({"bufnr" : []})', 'E730:')
20178
2fb397573541 patch 8.2.0644: insufficient testing for invalid function arguments
Bram Moolenaar <Bram@vim.org>
parents: 19642
diff changeset
1485 call assert_fails('call prop_find({})', 'E968:')
2fb397573541 patch 8.2.0644: insufficient testing for invalid function arguments
Bram Moolenaar <Bram@vim.org>
parents: 19642
diff changeset
1486 call assert_fails('call prop_find({}, "x")', 'E474:')
2fb397573541 patch 8.2.0644: insufficient testing for invalid function arguments
Bram Moolenaar <Bram@vim.org>
parents: 19642
diff changeset
1487 call assert_fails('call prop_find({"lnum" : -2})', 'E16:')
2fb397573541 patch 8.2.0644: insufficient testing for invalid function arguments
Bram Moolenaar <Bram@vim.org>
parents: 19642
diff changeset
1488 call assert_fails('call prop_list(1, [])', 'E715:')
21552
cbc570e66d11 patch 8.2.1326: Vim9: skipping over white space after list
Bram Moolenaar <Bram@vim.org>
parents: 21265
diff changeset
1489 call assert_fails('call prop_list(-1, {})', 'E16:')
20178
2fb397573541 patch 8.2.0644: insufficient testing for invalid function arguments
Bram Moolenaar <Bram@vim.org>
parents: 19642
diff changeset
1490 call assert_fails('call prop_remove([])', 'E474:')
2fb397573541 patch 8.2.0644: insufficient testing for invalid function arguments
Bram Moolenaar <Bram@vim.org>
parents: 19642
diff changeset
1491 call assert_fails('call prop_remove({}, -2)', 'E16:')
2fb397573541 patch 8.2.0644: insufficient testing for invalid function arguments
Bram Moolenaar <Bram@vim.org>
parents: 19642
diff changeset
1492 call assert_fails('call prop_remove({})', 'E968:')
21265
6a4806e326dd patch 8.2.1183: assert_fails() checks the last error message
Bram Moolenaar <Bram@vim.org>
parents: 20583
diff changeset
1493 call assert_fails('call prop_type_add([], {})', 'E730:')
20178
2fb397573541 patch 8.2.0644: insufficient testing for invalid function arguments
Bram Moolenaar <Bram@vim.org>
parents: 19642
diff changeset
1494 call assert_fails("call prop_type_change('long', {'xyz' : 10})", 'E971:')
21265
6a4806e326dd patch 8.2.1183: assert_fails() checks the last error message
Bram Moolenaar <Bram@vim.org>
parents: 20583
diff changeset
1495 call assert_fails("call prop_type_delete([])", 'E730:')
20178
2fb397573541 patch 8.2.0644: insufficient testing for invalid function arguments
Bram Moolenaar <Bram@vim.org>
parents: 19642
diff changeset
1496 call assert_fails("call prop_type_delete('xyz', [])", 'E715:')
21265
6a4806e326dd patch 8.2.1183: assert_fails() checks the last error message
Bram Moolenaar <Bram@vim.org>
parents: 20583
diff changeset
1497 call assert_fails("call prop_type_get([])", 'E730:')
20178
2fb397573541 patch 8.2.0644: insufficient testing for invalid function arguments
Bram Moolenaar <Bram@vim.org>
parents: 19642
diff changeset
1498 call assert_fails("call prop_type_get('', [])", 'E474:')
2fb397573541 patch 8.2.0644: insufficient testing for invalid function arguments
Bram Moolenaar <Bram@vim.org>
parents: 19642
diff changeset
1499 call assert_fails("call prop_type_list([])", 'E715:')
24039
a5478836fcb7 patch 8.2.2561: not all textprop code is covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 23901
diff changeset
1500 call assert_fails("call prop_type_add('yyy', 'not_a_dict')", 'E715:')
a5478836fcb7 patch 8.2.2561: not all textprop code is covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 23901
diff changeset
1501 call assert_fails("call prop_add(1, 5, {'type':'missing_type', 'length':1})", 'E971:')
a5478836fcb7 patch 8.2.2561: not all textprop code is covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 23901
diff changeset
1502 call assert_fails("call prop_add(1, 5, {'type': ''})", 'E971:')
a5478836fcb7 patch 8.2.2561: not all textprop code is covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 23901
diff changeset
1503 call assert_fails('call prop_add(1, 1, 0)', 'E715:')
a5478836fcb7 patch 8.2.2561: not all textprop code is covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 23901
diff changeset
1504
a5478836fcb7 patch 8.2.2561: not all textprop code is covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 23901
diff changeset
1505 new
a5478836fcb7 patch 8.2.2561: not all textprop code is covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 23901
diff changeset
1506 call setline(1, ['first', 'second'])
a5478836fcb7 patch 8.2.2561: not all textprop code is covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 23901
diff changeset
1507 call prop_type_add('xxx', {})
a5478836fcb7 patch 8.2.2561: not all textprop code is covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 23901
diff changeset
1508
a5478836fcb7 patch 8.2.2561: not all textprop code is covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 23901
diff changeset
1509 call assert_fails("call prop_type_add('xxx', {})", 'E969:')
a5478836fcb7 patch 8.2.2561: not all textprop code is covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 23901
diff changeset
1510 call assert_fails("call prop_add(2, 0, {'type': 'xxx'})", 'E964:')
a5478836fcb7 patch 8.2.2561: not all textprop code is covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 23901
diff changeset
1511 call assert_fails("call prop_add(2, 3, {'type': 'xxx', 'end_lnum':1})", 'E475:')
a5478836fcb7 patch 8.2.2561: not all textprop code is covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 23901
diff changeset
1512 call assert_fails("call prop_add(2, 3, {'type': 'xxx', 'end_lnum':3})", 'E966:')
a5478836fcb7 patch 8.2.2561: not all textprop code is covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 23901
diff changeset
1513 call assert_fails("call prop_add(2, 3, {'type': 'xxx', 'length':-1})", 'E475:')
a5478836fcb7 patch 8.2.2561: not all textprop code is covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 23901
diff changeset
1514 call assert_fails("call prop_add(2, 3, {'type': 'xxx', 'end_col':0})", 'E475:')
a5478836fcb7 patch 8.2.2561: not all textprop code is covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 23901
diff changeset
1515 call assert_fails("call prop_add(2, 3, {'length':1})", 'E965:')
a5478836fcb7 patch 8.2.2561: not all textprop code is covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 23901
diff changeset
1516
a5478836fcb7 patch 8.2.2561: not all textprop code is covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 23901
diff changeset
1517 call prop_type_delete('xxx')
a5478836fcb7 patch 8.2.2561: not all textprop code is covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 23901
diff changeset
1518 bwipe!
20178
2fb397573541 patch 8.2.0644: insufficient testing for invalid function arguments
Bram Moolenaar <Bram@vim.org>
parents: 19642
diff changeset
1519 endfunc
2fb397573541 patch 8.2.0644: insufficient testing for invalid function arguments
Bram Moolenaar <Bram@vim.org>
parents: 19642
diff changeset
1520
22278
0416105e103b patch 8.2.1688: increment/decrement removes text property
Bram Moolenaar <Bram@vim.org>
parents: 22147
diff changeset
1521 func Test_prop_split_join()
20583
d067be761cd7 patch 8.2.0845: text properties crossing lines not handled correctly
Bram Moolenaar <Bram@vim.org>
parents: 20178
diff changeset
1522 new
d067be761cd7 patch 8.2.0845: text properties crossing lines not handled correctly
Bram Moolenaar <Bram@vim.org>
parents: 20178
diff changeset
1523 call prop_type_add('test', {'highlight': 'ErrorMsg'})
d067be761cd7 patch 8.2.0845: text properties crossing lines not handled correctly
Bram Moolenaar <Bram@vim.org>
parents: 20178
diff changeset
1524 call setline(1, 'just some text')
d067be761cd7 patch 8.2.0845: text properties crossing lines not handled correctly
Bram Moolenaar <Bram@vim.org>
parents: 20178
diff changeset
1525 call prop_add(1, 6, {'length': 4, 'type': 'test'})
d067be761cd7 patch 8.2.0845: text properties crossing lines not handled correctly
Bram Moolenaar <Bram@vim.org>
parents: 20178
diff changeset
1526
d067be761cd7 patch 8.2.0845: text properties crossing lines not handled correctly
Bram Moolenaar <Bram@vim.org>
parents: 20178
diff changeset
1527 " Split in middle of "some"
d067be761cd7 patch 8.2.0845: text properties crossing lines not handled correctly
Bram Moolenaar <Bram@vim.org>
parents: 20178
diff changeset
1528 execute "normal! 8|i\<CR>"
25392
b427a26b0210 patch 8.2.3233: prop_list() and prop_find() do not indicate the buffer
Bram Moolenaar <Bram@vim.org>
parents: 25198
diff changeset
1529 call assert_equal(
b427a26b0210 patch 8.2.3233: prop_list() and prop_find() do not indicate the buffer
Bram Moolenaar <Bram@vim.org>
parents: 25198
diff changeset
1530 \ [#{type_bufnr: 0, id: 0, col: 6, end: 0, type: 'test', length: 2, start: 1}],
b427a26b0210 patch 8.2.3233: prop_list() and prop_find() do not indicate the buffer
Bram Moolenaar <Bram@vim.org>
parents: 25198
diff changeset
1531 \ prop_list(1))
b427a26b0210 patch 8.2.3233: prop_list() and prop_find() do not indicate the buffer
Bram Moolenaar <Bram@vim.org>
parents: 25198
diff changeset
1532 call assert_equal(
b427a26b0210 patch 8.2.3233: prop_list() and prop_find() do not indicate the buffer
Bram Moolenaar <Bram@vim.org>
parents: 25198
diff changeset
1533 \ [#{type_bufnr: 0, id: 0, col: 1, end: 1, type: 'test', length: 2, start: 0}],
b427a26b0210 patch 8.2.3233: prop_list() and prop_find() do not indicate the buffer
Bram Moolenaar <Bram@vim.org>
parents: 25198
diff changeset
1534 \ prop_list(2))
20583
d067be761cd7 patch 8.2.0845: text properties crossing lines not handled correctly
Bram Moolenaar <Bram@vim.org>
parents: 20178
diff changeset
1535
d067be761cd7 patch 8.2.0845: text properties crossing lines not handled correctly
Bram Moolenaar <Bram@vim.org>
parents: 20178
diff changeset
1536 " Join the two lines back together
d067be761cd7 patch 8.2.0845: text properties crossing lines not handled correctly
Bram Moolenaar <Bram@vim.org>
parents: 20178
diff changeset
1537 normal! 1GJ
25392
b427a26b0210 patch 8.2.3233: prop_list() and prop_find() do not indicate the buffer
Bram Moolenaar <Bram@vim.org>
parents: 25198
diff changeset
1538 call assert_equal([#{type_bufnr: 0, id: 0, col: 6, end: 1, type: 'test', length: 5, start: 1}], prop_list(1))
20583
d067be761cd7 patch 8.2.0845: text properties crossing lines not handled correctly
Bram Moolenaar <Bram@vim.org>
parents: 20178
diff changeset
1539
d067be761cd7 patch 8.2.0845: text properties crossing lines not handled correctly
Bram Moolenaar <Bram@vim.org>
parents: 20178
diff changeset
1540 bwipe!
d067be761cd7 patch 8.2.0845: text properties crossing lines not handled correctly
Bram Moolenaar <Bram@vim.org>
parents: 20178
diff changeset
1541 call prop_type_delete('test')
d067be761cd7 patch 8.2.0845: text properties crossing lines not handled correctly
Bram Moolenaar <Bram@vim.org>
parents: 20178
diff changeset
1542 endfunc
d067be761cd7 patch 8.2.0845: text properties crossing lines not handled correctly
Bram Moolenaar <Bram@vim.org>
parents: 20178
diff changeset
1543
22278
0416105e103b patch 8.2.1688: increment/decrement removes text property
Bram Moolenaar <Bram@vim.org>
parents: 22147
diff changeset
1544 func Test_prop_increment_decrement()
0416105e103b patch 8.2.1688: increment/decrement removes text property
Bram Moolenaar <Bram@vim.org>
parents: 22147
diff changeset
1545 new
0416105e103b patch 8.2.1688: increment/decrement removes text property
Bram Moolenaar <Bram@vim.org>
parents: 22147
diff changeset
1546 call prop_type_add('test', {'highlight': 'ErrorMsg'})
0416105e103b patch 8.2.1688: increment/decrement removes text property
Bram Moolenaar <Bram@vim.org>
parents: 22147
diff changeset
1547 call setline(1, 'its 998 times')
0416105e103b patch 8.2.1688: increment/decrement removes text property
Bram Moolenaar <Bram@vim.org>
parents: 22147
diff changeset
1548 call prop_add(1, 5, {'length': 3, 'type': 'test'})
0416105e103b patch 8.2.1688: increment/decrement removes text property
Bram Moolenaar <Bram@vim.org>
parents: 22147
diff changeset
1549
0416105e103b patch 8.2.1688: increment/decrement removes text property
Bram Moolenaar <Bram@vim.org>
parents: 22147
diff changeset
1550 exe "normal! 0f9\<C-A>"
0416105e103b patch 8.2.1688: increment/decrement removes text property
Bram Moolenaar <Bram@vim.org>
parents: 22147
diff changeset
1551 eval getline(1)->assert_equal('its 999 times')
0416105e103b patch 8.2.1688: increment/decrement removes text property
Bram Moolenaar <Bram@vim.org>
parents: 22147
diff changeset
1552 eval prop_list(1)->assert_equal([
25392
b427a26b0210 patch 8.2.3233: prop_list() and prop_find() do not indicate the buffer
Bram Moolenaar <Bram@vim.org>
parents: 25198
diff changeset
1553 \ #{type_bufnr: 0, id: 0, col: 5, end: 1, type: 'test', length: 3, start: 1}])
22278
0416105e103b patch 8.2.1688: increment/decrement removes text property
Bram Moolenaar <Bram@vim.org>
parents: 22147
diff changeset
1554
0416105e103b patch 8.2.1688: increment/decrement removes text property
Bram Moolenaar <Bram@vim.org>
parents: 22147
diff changeset
1555 exe "normal! 0f9\<C-A>"
0416105e103b patch 8.2.1688: increment/decrement removes text property
Bram Moolenaar <Bram@vim.org>
parents: 22147
diff changeset
1556 eval getline(1)->assert_equal('its 1000 times')
0416105e103b patch 8.2.1688: increment/decrement removes text property
Bram Moolenaar <Bram@vim.org>
parents: 22147
diff changeset
1557 eval prop_list(1)->assert_equal([
25392
b427a26b0210 patch 8.2.3233: prop_list() and prop_find() do not indicate the buffer
Bram Moolenaar <Bram@vim.org>
parents: 25198
diff changeset
1558 \ #{type_bufnr: 0, id: 0, col: 5, end: 1, type: 'test', length: 4, start: 1}])
22278
0416105e103b patch 8.2.1688: increment/decrement removes text property
Bram Moolenaar <Bram@vim.org>
parents: 22147
diff changeset
1559
0416105e103b patch 8.2.1688: increment/decrement removes text property
Bram Moolenaar <Bram@vim.org>
parents: 22147
diff changeset
1560 bwipe!
0416105e103b patch 8.2.1688: increment/decrement removes text property
Bram Moolenaar <Bram@vim.org>
parents: 22147
diff changeset
1561 call prop_type_delete('test')
0416105e103b patch 8.2.1688: increment/decrement removes text property
Bram Moolenaar <Bram@vim.org>
parents: 22147
diff changeset
1562 endfunc
0416105e103b patch 8.2.1688: increment/decrement removes text property
Bram Moolenaar <Bram@vim.org>
parents: 22147
diff changeset
1563
22282
5adb97bf0b32 patch 8.2.1690: text properties not adjusted for "I" in Visual block mode
Bram Moolenaar <Bram@vim.org>
parents: 22278
diff changeset
1564 func Test_prop_block_insert()
5adb97bf0b32 patch 8.2.1690: text properties not adjusted for "I" in Visual block mode
Bram Moolenaar <Bram@vim.org>
parents: 22278
diff changeset
1565 new
5adb97bf0b32 patch 8.2.1690: text properties not adjusted for "I" in Visual block mode
Bram Moolenaar <Bram@vim.org>
parents: 22278
diff changeset
1566 call prop_type_add('test', {'highlight': 'ErrorMsg'})
5adb97bf0b32 patch 8.2.1690: text properties not adjusted for "I" in Visual block mode
Bram Moolenaar <Bram@vim.org>
parents: 22278
diff changeset
1567 call setline(1, ['one ', 'two '])
5adb97bf0b32 patch 8.2.1690: text properties not adjusted for "I" in Visual block mode
Bram Moolenaar <Bram@vim.org>
parents: 22278
diff changeset
1568 call prop_add(1, 1, {'length': 3, 'type': 'test'})
5adb97bf0b32 patch 8.2.1690: text properties not adjusted for "I" in Visual block mode
Bram Moolenaar <Bram@vim.org>
parents: 22278
diff changeset
1569 call prop_add(2, 1, {'length': 3, 'type': 'test'})
5adb97bf0b32 patch 8.2.1690: text properties not adjusted for "I" in Visual block mode
Bram Moolenaar <Bram@vim.org>
parents: 22278
diff changeset
1570
5adb97bf0b32 patch 8.2.1690: text properties not adjusted for "I" in Visual block mode
Bram Moolenaar <Bram@vim.org>
parents: 22278
diff changeset
1571 " insert "xx" in the first column of both lines
5adb97bf0b32 patch 8.2.1690: text properties not adjusted for "I" in Visual block mode
Bram Moolenaar <Bram@vim.org>
parents: 22278
diff changeset
1572 exe "normal! gg0\<C-V>jIxx\<Esc>"
5adb97bf0b32 patch 8.2.1690: text properties not adjusted for "I" in Visual block mode
Bram Moolenaar <Bram@vim.org>
parents: 22278
diff changeset
1573 eval getline(1, 2)->assert_equal(['xxone ', 'xxtwo '])
25392
b427a26b0210 patch 8.2.3233: prop_list() and prop_find() do not indicate the buffer
Bram Moolenaar <Bram@vim.org>
parents: 25198
diff changeset
1574 let expected = [#{type_bufnr: 0, id: 0, col: 3, end: 1, type: 'test', length: 3, start: 1}]
22282
5adb97bf0b32 patch 8.2.1690: text properties not adjusted for "I" in Visual block mode
Bram Moolenaar <Bram@vim.org>
parents: 22278
diff changeset
1575 eval prop_list(1)->assert_equal(expected)
5adb97bf0b32 patch 8.2.1690: text properties not adjusted for "I" in Visual block mode
Bram Moolenaar <Bram@vim.org>
parents: 22278
diff changeset
1576 eval prop_list(2)->assert_equal(expected)
5adb97bf0b32 patch 8.2.1690: text properties not adjusted for "I" in Visual block mode
Bram Moolenaar <Bram@vim.org>
parents: 22278
diff changeset
1577
5adb97bf0b32 patch 8.2.1690: text properties not adjusted for "I" in Visual block mode
Bram Moolenaar <Bram@vim.org>
parents: 22278
diff changeset
1578 " insert "yy" inside the text props to make them longer
5adb97bf0b32 patch 8.2.1690: text properties not adjusted for "I" in Visual block mode
Bram Moolenaar <Bram@vim.org>
parents: 22278
diff changeset
1579 exe "normal! gg03l\<C-V>jIyy\<Esc>"
5adb97bf0b32 patch 8.2.1690: text properties not adjusted for "I" in Visual block mode
Bram Moolenaar <Bram@vim.org>
parents: 22278
diff changeset
1580 eval getline(1, 2)->assert_equal(['xxoyyne ', 'xxtyywo '])
5adb97bf0b32 patch 8.2.1690: text properties not adjusted for "I" in Visual block mode
Bram Moolenaar <Bram@vim.org>
parents: 22278
diff changeset
1581 let expected[0].length = 5
5adb97bf0b32 patch 8.2.1690: text properties not adjusted for "I" in Visual block mode
Bram Moolenaar <Bram@vim.org>
parents: 22278
diff changeset
1582 eval prop_list(1)->assert_equal(expected)
5adb97bf0b32 patch 8.2.1690: text properties not adjusted for "I" in Visual block mode
Bram Moolenaar <Bram@vim.org>
parents: 22278
diff changeset
1583 eval prop_list(2)->assert_equal(expected)
5adb97bf0b32 patch 8.2.1690: text properties not adjusted for "I" in Visual block mode
Bram Moolenaar <Bram@vim.org>
parents: 22278
diff changeset
1584
5adb97bf0b32 patch 8.2.1690: text properties not adjusted for "I" in Visual block mode
Bram Moolenaar <Bram@vim.org>
parents: 22278
diff changeset
1585 " insert "zz" after the text props, text props don't change
5adb97bf0b32 patch 8.2.1690: text properties not adjusted for "I" in Visual block mode
Bram Moolenaar <Bram@vim.org>
parents: 22278
diff changeset
1586 exe "normal! gg07l\<C-V>jIzz\<Esc>"
5adb97bf0b32 patch 8.2.1690: text properties not adjusted for "I" in Visual block mode
Bram Moolenaar <Bram@vim.org>
parents: 22278
diff changeset
1587 eval getline(1, 2)->assert_equal(['xxoyynezz ', 'xxtyywozz '])
5adb97bf0b32 patch 8.2.1690: text properties not adjusted for "I" in Visual block mode
Bram Moolenaar <Bram@vim.org>
parents: 22278
diff changeset
1588 eval prop_list(1)->assert_equal(expected)
5adb97bf0b32 patch 8.2.1690: text properties not adjusted for "I" in Visual block mode
Bram Moolenaar <Bram@vim.org>
parents: 22278
diff changeset
1589 eval prop_list(2)->assert_equal(expected)
5adb97bf0b32 patch 8.2.1690: text properties not adjusted for "I" in Visual block mode
Bram Moolenaar <Bram@vim.org>
parents: 22278
diff changeset
1590
5adb97bf0b32 patch 8.2.1690: text properties not adjusted for "I" in Visual block mode
Bram Moolenaar <Bram@vim.org>
parents: 22278
diff changeset
1591 bwipe!
5adb97bf0b32 patch 8.2.1690: text properties not adjusted for "I" in Visual block mode
Bram Moolenaar <Bram@vim.org>
parents: 22278
diff changeset
1592 call prop_type_delete('test')
5adb97bf0b32 patch 8.2.1690: text properties not adjusted for "I" in Visual block mode
Bram Moolenaar <Bram@vim.org>
parents: 22278
diff changeset
1593 endfunc
5adb97bf0b32 patch 8.2.1690: text properties not adjusted for "I" in Visual block mode
Bram Moolenaar <Bram@vim.org>
parents: 22278
diff changeset
1594
23306
90ea5037a7e3 patch 8.2.2198: ml_get error when resizing window and using text property
Bram Moolenaar <Bram@vim.org>
parents: 23072
diff changeset
1595 " this was causing an ml_get error because w_botline was wrong
90ea5037a7e3 patch 8.2.2198: ml_get error when resizing window and using text property
Bram Moolenaar <Bram@vim.org>
parents: 23072
diff changeset
1596 func Test_prop_one_line_window()
90ea5037a7e3 patch 8.2.2198: ml_get error when resizing window and using text property
Bram Moolenaar <Bram@vim.org>
parents: 23072
diff changeset
1597 enew
90ea5037a7e3 patch 8.2.2198: ml_get error when resizing window and using text property
Bram Moolenaar <Bram@vim.org>
parents: 23072
diff changeset
1598 call range(2)->setline(1)
90ea5037a7e3 patch 8.2.2198: ml_get error when resizing window and using text property
Bram Moolenaar <Bram@vim.org>
parents: 23072
diff changeset
1599 call prop_type_add('testprop', {})
90ea5037a7e3 patch 8.2.2198: ml_get error when resizing window and using text property
Bram Moolenaar <Bram@vim.org>
parents: 23072
diff changeset
1600 call prop_add(1, 1, {'type': 'testprop'})
90ea5037a7e3 patch 8.2.2198: ml_get error when resizing window and using text property
Bram Moolenaar <Bram@vim.org>
parents: 23072
diff changeset
1601 call popup_create('popup', {'textprop': 'testprop'})
90ea5037a7e3 patch 8.2.2198: ml_get error when resizing window and using text property
Bram Moolenaar <Bram@vim.org>
parents: 23072
diff changeset
1602 $
90ea5037a7e3 patch 8.2.2198: ml_get error when resizing window and using text property
Bram Moolenaar <Bram@vim.org>
parents: 23072
diff changeset
1603 new
90ea5037a7e3 patch 8.2.2198: ml_get error when resizing window and using text property
Bram Moolenaar <Bram@vim.org>
parents: 23072
diff changeset
1604 wincmd _
90ea5037a7e3 patch 8.2.2198: ml_get error when resizing window and using text property
Bram Moolenaar <Bram@vim.org>
parents: 23072
diff changeset
1605 call feedkeys("\r", 'xt')
90ea5037a7e3 patch 8.2.2198: ml_get error when resizing window and using text property
Bram Moolenaar <Bram@vim.org>
parents: 23072
diff changeset
1606 redraw
90ea5037a7e3 patch 8.2.2198: ml_get error when resizing window and using text property
Bram Moolenaar <Bram@vim.org>
parents: 23072
diff changeset
1607
90ea5037a7e3 patch 8.2.2198: ml_get error when resizing window and using text property
Bram Moolenaar <Bram@vim.org>
parents: 23072
diff changeset
1608 call popup_clear()
90ea5037a7e3 patch 8.2.2198: ml_get error when resizing window and using text property
Bram Moolenaar <Bram@vim.org>
parents: 23072
diff changeset
1609 call prop_type_delete('testprop')
90ea5037a7e3 patch 8.2.2198: ml_get error when resizing window and using text property
Bram Moolenaar <Bram@vim.org>
parents: 23072
diff changeset
1610 close
90ea5037a7e3 patch 8.2.2198: ml_get error when resizing window and using text property
Bram Moolenaar <Bram@vim.org>
parents: 23072
diff changeset
1611 bwipe!
90ea5037a7e3 patch 8.2.2198: ml_get error when resizing window and using text property
Bram Moolenaar <Bram@vim.org>
parents: 23072
diff changeset
1612 endfunc
90ea5037a7e3 patch 8.2.2198: ml_get error when resizing window and using text property
Bram Moolenaar <Bram@vim.org>
parents: 23072
diff changeset
1613
24703
4bc0bda6857d patch 8.2.2890: text property duplicated when data block splits
Bram Moolenaar <Bram@vim.org>
parents: 24252
diff changeset
1614 " This was calling ml_append_int() and copy a text property from a previous
4bc0bda6857d patch 8.2.2890: text property duplicated when data block splits
Bram Moolenaar <Bram@vim.org>
parents: 24252
diff changeset
1615 " line at the wrong moment. Exact text length matters.
4bc0bda6857d patch 8.2.2890: text property duplicated when data block splits
Bram Moolenaar <Bram@vim.org>
parents: 24252
diff changeset
1616 def Test_prop_splits_data_block()
4bc0bda6857d patch 8.2.2890: text property duplicated when data block splits
Bram Moolenaar <Bram@vim.org>
parents: 24252
diff changeset
1617 new
4bc0bda6857d patch 8.2.2890: text property duplicated when data block splits
Bram Moolenaar <Bram@vim.org>
parents: 24252
diff changeset
1618 var lines: list<string> = [repeat('x', 35)]->repeat(41)
4bc0bda6857d patch 8.2.2890: text property duplicated when data block splits
Bram Moolenaar <Bram@vim.org>
parents: 24252
diff changeset
1619 + [repeat('!', 35)]
4bc0bda6857d patch 8.2.2890: text property duplicated when data block splits
Bram Moolenaar <Bram@vim.org>
parents: 24252
diff changeset
1620 + [repeat('x', 35)]->repeat(56)
4bc0bda6857d patch 8.2.2890: text property duplicated when data block splits
Bram Moolenaar <Bram@vim.org>
parents: 24252
diff changeset
1621 lines->setline(1)
4bc0bda6857d patch 8.2.2890: text property duplicated when data block splits
Bram Moolenaar <Bram@vim.org>
parents: 24252
diff changeset
1622 prop_type_add('someprop', {highlight: 'ErrorMsg'})
4bc0bda6857d patch 8.2.2890: text property duplicated when data block splits
Bram Moolenaar <Bram@vim.org>
parents: 24252
diff changeset
1623 prop_add(1, 27, {end_lnum: 1, end_col: 70, type: 'someprop'})
4bc0bda6857d patch 8.2.2890: text property duplicated when data block splits
Bram Moolenaar <Bram@vim.org>
parents: 24252
diff changeset
1624 prop_remove({type: 'someprop'}, 1)
4bc0bda6857d patch 8.2.2890: text property duplicated when data block splits
Bram Moolenaar <Bram@vim.org>
parents: 24252
diff changeset
1625 prop_add(35, 22, {end_lnum: 43, end_col: 43, type: 'someprop'})
4bc0bda6857d patch 8.2.2890: text property duplicated when data block splits
Bram Moolenaar <Bram@vim.org>
parents: 24252
diff changeset
1626 prop_remove({type: 'someprop'}, 35, 43)
4bc0bda6857d patch 8.2.2890: text property duplicated when data block splits
Bram Moolenaar <Bram@vim.org>
parents: 24252
diff changeset
1627 assert_equal([], prop_list(42))
4bc0bda6857d patch 8.2.2890: text property duplicated when data block splits
Bram Moolenaar <Bram@vim.org>
parents: 24252
diff changeset
1628
4bc0bda6857d patch 8.2.2890: text property duplicated when data block splits
Bram Moolenaar <Bram@vim.org>
parents: 24252
diff changeset
1629 bwipe!
4bc0bda6857d patch 8.2.2890: text property duplicated when data block splits
Bram Moolenaar <Bram@vim.org>
parents: 24252
diff changeset
1630 prop_type_delete('someprop')
4bc0bda6857d patch 8.2.2890: text property duplicated when data block splits
Bram Moolenaar <Bram@vim.org>
parents: 24252
diff changeset
1631 enddef
4bc0bda6857d patch 8.2.2890: text property duplicated when data block splits
Bram Moolenaar <Bram@vim.org>
parents: 24252
diff changeset
1632
25050
7ef7a211f6bf patch 8.2.3062: internal error when adding several text properties
Bram Moolenaar <Bram@vim.org>
parents: 24703
diff changeset
1633 " This was calling ml_delete_int() and try to change text properties.
7ef7a211f6bf patch 8.2.3062: internal error when adding several text properties
Bram Moolenaar <Bram@vim.org>
parents: 24703
diff changeset
1634 def Test_prop_add_delete_line()
7ef7a211f6bf patch 8.2.3062: internal error when adding several text properties
Bram Moolenaar <Bram@vim.org>
parents: 24703
diff changeset
1635 new
7ef7a211f6bf patch 8.2.3062: internal error when adding several text properties
Bram Moolenaar <Bram@vim.org>
parents: 24703
diff changeset
1636 var a = 10
7ef7a211f6bf patch 8.2.3062: internal error when adding several text properties
Bram Moolenaar <Bram@vim.org>
parents: 24703
diff changeset
1637 var b = 20
7ef7a211f6bf patch 8.2.3062: internal error when adding several text properties
Bram Moolenaar <Bram@vim.org>
parents: 24703
diff changeset
1638 repeat([''], a)->append('$')
7ef7a211f6bf patch 8.2.3062: internal error when adding several text properties
Bram Moolenaar <Bram@vim.org>
parents: 24703
diff changeset
1639 prop_type_add('Test', {highlight: 'ErrorMsg'})
7ef7a211f6bf patch 8.2.3062: internal error when adding several text properties
Bram Moolenaar <Bram@vim.org>
parents: 24703
diff changeset
1640 for lnum in range(1, a)
7ef7a211f6bf patch 8.2.3062: internal error when adding several text properties
Bram Moolenaar <Bram@vim.org>
parents: 24703
diff changeset
1641 for col in range(1, b)
7ef7a211f6bf patch 8.2.3062: internal error when adding several text properties
Bram Moolenaar <Bram@vim.org>
parents: 24703
diff changeset
1642 prop_add(1, 1, {end_lnum: lnum, end_col: col, type: 'Test'})
7ef7a211f6bf patch 8.2.3062: internal error when adding several text properties
Bram Moolenaar <Bram@vim.org>
parents: 24703
diff changeset
1643 endfor
7ef7a211f6bf patch 8.2.3062: internal error when adding several text properties
Bram Moolenaar <Bram@vim.org>
parents: 24703
diff changeset
1644 endfor
7ef7a211f6bf patch 8.2.3062: internal error when adding several text properties
Bram Moolenaar <Bram@vim.org>
parents: 24703
diff changeset
1645
7ef7a211f6bf patch 8.2.3062: internal error when adding several text properties
Bram Moolenaar <Bram@vim.org>
parents: 24703
diff changeset
1646 # check deleting lines is OK
7ef7a211f6bf patch 8.2.3062: internal error when adding several text properties
Bram Moolenaar <Bram@vim.org>
parents: 24703
diff changeset
1647 :5del
7ef7a211f6bf patch 8.2.3062: internal error when adding several text properties
Bram Moolenaar <Bram@vim.org>
parents: 24703
diff changeset
1648 :1del
7ef7a211f6bf patch 8.2.3062: internal error when adding several text properties
Bram Moolenaar <Bram@vim.org>
parents: 24703
diff changeset
1649 :$del
7ef7a211f6bf patch 8.2.3062: internal error when adding several text properties
Bram Moolenaar <Bram@vim.org>
parents: 24703
diff changeset
1650
7ef7a211f6bf patch 8.2.3062: internal error when adding several text properties
Bram Moolenaar <Bram@vim.org>
parents: 24703
diff changeset
1651 prop_type_delete('Test')
7ef7a211f6bf patch 8.2.3062: internal error when adding several text properties
Bram Moolenaar <Bram@vim.org>
parents: 24703
diff changeset
1652 bwipe!
7ef7a211f6bf patch 8.2.3062: internal error when adding several text properties
Bram Moolenaar <Bram@vim.org>
parents: 24703
diff changeset
1653 enddef
7ef7a211f6bf patch 8.2.3062: internal error when adding several text properties
Bram Moolenaar <Bram@vim.org>
parents: 24703
diff changeset
1654
28875
78ebb50d6fcb patch 8.2.4960: text properties that cross lines not updated for deleted line
Bram Moolenaar <Bram@vim.org>
parents: 28869
diff changeset
1655 " This test is to detect a regression related to #10430. It is not an attempt
78ebb50d6fcb patch 8.2.4960: text properties that cross lines not updated for deleted line
Bram Moolenaar <Bram@vim.org>
parents: 28869
diff changeset
1656 " fully cover deleting lines in the presence of multi-line properties.
78ebb50d6fcb patch 8.2.4960: text properties that cross lines not updated for deleted line
Bram Moolenaar <Bram@vim.org>
parents: 28869
diff changeset
1657 def Test_delete_line_within_multiline_prop()
78ebb50d6fcb patch 8.2.4960: text properties that cross lines not updated for deleted line
Bram Moolenaar <Bram@vim.org>
parents: 28869
diff changeset
1658 new
78ebb50d6fcb patch 8.2.4960: text properties that cross lines not updated for deleted line
Bram Moolenaar <Bram@vim.org>
parents: 28869
diff changeset
1659 setline(1, '# Top.')
78ebb50d6fcb patch 8.2.4960: text properties that cross lines not updated for deleted line
Bram Moolenaar <Bram@vim.org>
parents: 28869
diff changeset
1660 append(1, ['some_text = """', 'A string.', '"""', '# Bottom.'])
78ebb50d6fcb patch 8.2.4960: text properties that cross lines not updated for deleted line
Bram Moolenaar <Bram@vim.org>
parents: 28869
diff changeset
1661 prop_type_add('Identifier', {'highlight': 'ModeMsg', 'priority': 0, 'combine': 0, 'start_incl': 0, 'end_incl': 0})
78ebb50d6fcb patch 8.2.4960: text properties that cross lines not updated for deleted line
Bram Moolenaar <Bram@vim.org>
parents: 28869
diff changeset
1662 prop_type_add('String', {'highlight': 'MoreMsg', 'priority': 0, 'combine': 0, 'start_incl': 0, 'end_incl': 0})
78ebb50d6fcb patch 8.2.4960: text properties that cross lines not updated for deleted line
Bram Moolenaar <Bram@vim.org>
parents: 28869
diff changeset
1663 prop_add(2, 1, {'type': 'Identifier', 'end_lnum': 2, 'end_col': 9})
78ebb50d6fcb patch 8.2.4960: text properties that cross lines not updated for deleted line
Bram Moolenaar <Bram@vim.org>
parents: 28869
diff changeset
1664 prop_add(2, 13, {'type': 'String', 'end_lnum': 4, 'end_col': 4})
78ebb50d6fcb patch 8.2.4960: text properties that cross lines not updated for deleted line
Bram Moolenaar <Bram@vim.org>
parents: 28869
diff changeset
1665
78ebb50d6fcb patch 8.2.4960: text properties that cross lines not updated for deleted line
Bram Moolenaar <Bram@vim.org>
parents: 28869
diff changeset
1666 # The property for line 3 should extend into the previous and next lines.
78ebb50d6fcb patch 8.2.4960: text properties that cross lines not updated for deleted line
Bram Moolenaar <Bram@vim.org>
parents: 28869
diff changeset
1667 var props = prop_list(3)
78ebb50d6fcb patch 8.2.4960: text properties that cross lines not updated for deleted line
Bram Moolenaar <Bram@vim.org>
parents: 28869
diff changeset
1668 var prop = props[0]
78ebb50d6fcb patch 8.2.4960: text properties that cross lines not updated for deleted line
Bram Moolenaar <Bram@vim.org>
parents: 28869
diff changeset
1669 assert_equal(1, len(props))
78ebb50d6fcb patch 8.2.4960: text properties that cross lines not updated for deleted line
Bram Moolenaar <Bram@vim.org>
parents: 28869
diff changeset
1670 assert_equal(0, prop['start'])
78ebb50d6fcb patch 8.2.4960: text properties that cross lines not updated for deleted line
Bram Moolenaar <Bram@vim.org>
parents: 28869
diff changeset
1671 assert_equal(0, prop['end'])
78ebb50d6fcb patch 8.2.4960: text properties that cross lines not updated for deleted line
Bram Moolenaar <Bram@vim.org>
parents: 28869
diff changeset
1672
78ebb50d6fcb patch 8.2.4960: text properties that cross lines not updated for deleted line
Bram Moolenaar <Bram@vim.org>
parents: 28869
diff changeset
1673 # This deletion should run without raising an exception.
78ebb50d6fcb patch 8.2.4960: text properties that cross lines not updated for deleted line
Bram Moolenaar <Bram@vim.org>
parents: 28869
diff changeset
1674 try
78ebb50d6fcb patch 8.2.4960: text properties that cross lines not updated for deleted line
Bram Moolenaar <Bram@vim.org>
parents: 28869
diff changeset
1675 :2 del
78ebb50d6fcb patch 8.2.4960: text properties that cross lines not updated for deleted line
Bram Moolenaar <Bram@vim.org>
parents: 28869
diff changeset
1676 catch
78ebb50d6fcb patch 8.2.4960: text properties that cross lines not updated for deleted line
Bram Moolenaar <Bram@vim.org>
parents: 28869
diff changeset
1677 assert_report('Line delete should have workd, but it raised an error.')
78ebb50d6fcb patch 8.2.4960: text properties that cross lines not updated for deleted line
Bram Moolenaar <Bram@vim.org>
parents: 28869
diff changeset
1678 endtry
78ebb50d6fcb patch 8.2.4960: text properties that cross lines not updated for deleted line
Bram Moolenaar <Bram@vim.org>
parents: 28869
diff changeset
1679
78ebb50d6fcb patch 8.2.4960: text properties that cross lines not updated for deleted line
Bram Moolenaar <Bram@vim.org>
parents: 28869
diff changeset
1680 # The property for line 2 (was 3) should no longer extend into the previous
78ebb50d6fcb patch 8.2.4960: text properties that cross lines not updated for deleted line
Bram Moolenaar <Bram@vim.org>
parents: 28869
diff changeset
1681 # line.
78ebb50d6fcb patch 8.2.4960: text properties that cross lines not updated for deleted line
Bram Moolenaar <Bram@vim.org>
parents: 28869
diff changeset
1682 props = prop_list(2)
78ebb50d6fcb patch 8.2.4960: text properties that cross lines not updated for deleted line
Bram Moolenaar <Bram@vim.org>
parents: 28869
diff changeset
1683 prop = props[0]
78ebb50d6fcb patch 8.2.4960: text properties that cross lines not updated for deleted line
Bram Moolenaar <Bram@vim.org>
parents: 28869
diff changeset
1684 assert_equal(1, len(props))
78ebb50d6fcb patch 8.2.4960: text properties that cross lines not updated for deleted line
Bram Moolenaar <Bram@vim.org>
parents: 28869
diff changeset
1685 assert_equal(1, prop['start'], 'Property was not changed to start within the line.')
78ebb50d6fcb patch 8.2.4960: text properties that cross lines not updated for deleted line
Bram Moolenaar <Bram@vim.org>
parents: 28869
diff changeset
1686
78ebb50d6fcb patch 8.2.4960: text properties that cross lines not updated for deleted line
Bram Moolenaar <Bram@vim.org>
parents: 28869
diff changeset
1687 # This deletion should run without raising an exception.
78ebb50d6fcb patch 8.2.4960: text properties that cross lines not updated for deleted line
Bram Moolenaar <Bram@vim.org>
parents: 28869
diff changeset
1688 try
78ebb50d6fcb patch 8.2.4960: text properties that cross lines not updated for deleted line
Bram Moolenaar <Bram@vim.org>
parents: 28869
diff changeset
1689 :3 del
78ebb50d6fcb patch 8.2.4960: text properties that cross lines not updated for deleted line
Bram Moolenaar <Bram@vim.org>
parents: 28869
diff changeset
1690 catch
78ebb50d6fcb patch 8.2.4960: text properties that cross lines not updated for deleted line
Bram Moolenaar <Bram@vim.org>
parents: 28869
diff changeset
1691 assert_report('Line delete should have workd, but it raised an error.')
78ebb50d6fcb patch 8.2.4960: text properties that cross lines not updated for deleted line
Bram Moolenaar <Bram@vim.org>
parents: 28869
diff changeset
1692 endtry
78ebb50d6fcb patch 8.2.4960: text properties that cross lines not updated for deleted line
Bram Moolenaar <Bram@vim.org>
parents: 28869
diff changeset
1693
78ebb50d6fcb patch 8.2.4960: text properties that cross lines not updated for deleted line
Bram Moolenaar <Bram@vim.org>
parents: 28869
diff changeset
1694 # The property for line 2 (originally 3) should no longer extend into the next
78ebb50d6fcb patch 8.2.4960: text properties that cross lines not updated for deleted line
Bram Moolenaar <Bram@vim.org>
parents: 28869
diff changeset
1695 # line.
78ebb50d6fcb patch 8.2.4960: text properties that cross lines not updated for deleted line
Bram Moolenaar <Bram@vim.org>
parents: 28869
diff changeset
1696 props = prop_list(2)
78ebb50d6fcb patch 8.2.4960: text properties that cross lines not updated for deleted line
Bram Moolenaar <Bram@vim.org>
parents: 28869
diff changeset
1697 prop = props[0]
78ebb50d6fcb patch 8.2.4960: text properties that cross lines not updated for deleted line
Bram Moolenaar <Bram@vim.org>
parents: 28869
diff changeset
1698 assert_equal(1, len(props))
78ebb50d6fcb patch 8.2.4960: text properties that cross lines not updated for deleted line
Bram Moolenaar <Bram@vim.org>
parents: 28869
diff changeset
1699 assert_equal(1, prop['end'], 'Property was not changed to end within the line.')
78ebb50d6fcb patch 8.2.4960: text properties that cross lines not updated for deleted line
Bram Moolenaar <Bram@vim.org>
parents: 28869
diff changeset
1700
78ebb50d6fcb patch 8.2.4960: text properties that cross lines not updated for deleted line
Bram Moolenaar <Bram@vim.org>
parents: 28869
diff changeset
1701 prop_type_delete('Identifier')
78ebb50d6fcb patch 8.2.4960: text properties that cross lines not updated for deleted line
Bram Moolenaar <Bram@vim.org>
parents: 28869
diff changeset
1702 prop_type_delete('String')
78ebb50d6fcb patch 8.2.4960: text properties that cross lines not updated for deleted line
Bram Moolenaar <Bram@vim.org>
parents: 28869
diff changeset
1703 bwip!
78ebb50d6fcb patch 8.2.4960: text properties that cross lines not updated for deleted line
Bram Moolenaar <Bram@vim.org>
parents: 28869
diff changeset
1704 enddef
78ebb50d6fcb patch 8.2.4960: text properties that cross lines not updated for deleted line
Bram Moolenaar <Bram@vim.org>
parents: 28869
diff changeset
1705
26338
4cf208415483 patch 8.2.3700: text property highlighting continues over breakindent
Bram Moolenaar <Bram@vim.org>
parents: 26242
diff changeset
1706 func Test_prop_in_linebreak()
4cf208415483 patch 8.2.3700: text property highlighting continues over breakindent
Bram Moolenaar <Bram@vim.org>
parents: 26242
diff changeset
1707 CheckRunVimInTerminal
4cf208415483 patch 8.2.3700: text property highlighting continues over breakindent
Bram Moolenaar <Bram@vim.org>
parents: 26242
diff changeset
1708
4cf208415483 patch 8.2.3700: text property highlighting continues over breakindent
Bram Moolenaar <Bram@vim.org>
parents: 26242
diff changeset
1709 let lines =<< trim END
4cf208415483 patch 8.2.3700: text property highlighting continues over breakindent
Bram Moolenaar <Bram@vim.org>
parents: 26242
diff changeset
1710 set breakindent linebreak breakat+=]
4cf208415483 patch 8.2.3700: text property highlighting continues over breakindent
Bram Moolenaar <Bram@vim.org>
parents: 26242
diff changeset
1711 call printf('%s]%s', repeat('x', 50), repeat('x', 70))->setline(1)
4cf208415483 patch 8.2.3700: text property highlighting continues over breakindent
Bram Moolenaar <Bram@vim.org>
parents: 26242
diff changeset
1712 call prop_type_add('test', #{highlight: 'ErrorMsg'})
4cf208415483 patch 8.2.3700: text property highlighting continues over breakindent
Bram Moolenaar <Bram@vim.org>
parents: 26242
diff changeset
1713 call prop_add(1, 51, #{length: 1, type: 'test'})
4cf208415483 patch 8.2.3700: text property highlighting continues over breakindent
Bram Moolenaar <Bram@vim.org>
parents: 26242
diff changeset
1714 END
4cf208415483 patch 8.2.3700: text property highlighting continues over breakindent
Bram Moolenaar <Bram@vim.org>
parents: 26242
diff changeset
1715 call writefile(lines, 'XscriptPropLinebreak')
4cf208415483 patch 8.2.3700: text property highlighting continues over breakindent
Bram Moolenaar <Bram@vim.org>
parents: 26242
diff changeset
1716 let buf = RunVimInTerminal('-S XscriptPropLinebreak', #{rows: 10})
4cf208415483 patch 8.2.3700: text property highlighting continues over breakindent
Bram Moolenaar <Bram@vim.org>
parents: 26242
diff changeset
1717 call VerifyScreenDump(buf, 'Test_prop_linebreak', {})
4cf208415483 patch 8.2.3700: text property highlighting continues over breakindent
Bram Moolenaar <Bram@vim.org>
parents: 26242
diff changeset
1718
4cf208415483 patch 8.2.3700: text property highlighting continues over breakindent
Bram Moolenaar <Bram@vim.org>
parents: 26242
diff changeset
1719 call StopVimInTerminal(buf)
4cf208415483 patch 8.2.3700: text property highlighting continues over breakindent
Bram Moolenaar <Bram@vim.org>
parents: 26242
diff changeset
1720 call delete('XscriptPropLinebreak')
4cf208415483 patch 8.2.3700: text property highlighting continues over breakindent
Bram Moolenaar <Bram@vim.org>
parents: 26242
diff changeset
1721 endfunc
4cf208415483 patch 8.2.3700: text property highlighting continues over breakindent
Bram Moolenaar <Bram@vim.org>
parents: 26242
diff changeset
1722
26350
13cce5c82c9a patch 8.2.3706: text property highlighting is used on Tab
Bram Moolenaar <Bram@vim.org>
parents: 26338
diff changeset
1723 func Test_prop_after_tab()
13cce5c82c9a patch 8.2.3706: text property highlighting is used on Tab
Bram Moolenaar <Bram@vim.org>
parents: 26338
diff changeset
1724 CheckRunVimInTerminal
13cce5c82c9a patch 8.2.3706: text property highlighting is used on Tab
Bram Moolenaar <Bram@vim.org>
parents: 26338
diff changeset
1725
13cce5c82c9a patch 8.2.3706: text property highlighting is used on Tab
Bram Moolenaar <Bram@vim.org>
parents: 26338
diff changeset
1726 let lines =<< trim END
13cce5c82c9a patch 8.2.3706: text property highlighting is used on Tab
Bram Moolenaar <Bram@vim.org>
parents: 26338
diff changeset
1727 set breakindent linebreak breakat+=]
13cce5c82c9a patch 8.2.3706: text property highlighting is used on Tab
Bram Moolenaar <Bram@vim.org>
parents: 26338
diff changeset
1728 call setline(1, "\t[xxx]")
13cce5c82c9a patch 8.2.3706: text property highlighting is used on Tab
Bram Moolenaar <Bram@vim.org>
parents: 26338
diff changeset
1729 call prop_type_add('test', #{highlight: 'ErrorMsg'})
13cce5c82c9a patch 8.2.3706: text property highlighting is used on Tab
Bram Moolenaar <Bram@vim.org>
parents: 26338
diff changeset
1730 call prop_add(1, 2, #{length: 1, type: 'test'})
13cce5c82c9a patch 8.2.3706: text property highlighting is used on Tab
Bram Moolenaar <Bram@vim.org>
parents: 26338
diff changeset
1731 END
13cce5c82c9a patch 8.2.3706: text property highlighting is used on Tab
Bram Moolenaar <Bram@vim.org>
parents: 26338
diff changeset
1732 call writefile(lines, 'XscriptPropAfterTab')
13cce5c82c9a patch 8.2.3706: text property highlighting is used on Tab
Bram Moolenaar <Bram@vim.org>
parents: 26338
diff changeset
1733 let buf = RunVimInTerminal('-S XscriptPropAfterTab', #{rows: 10})
13cce5c82c9a patch 8.2.3706: text property highlighting is used on Tab
Bram Moolenaar <Bram@vim.org>
parents: 26338
diff changeset
1734 call VerifyScreenDump(buf, 'Test_prop_after_tab', {})
13cce5c82c9a patch 8.2.3706: text property highlighting is used on Tab
Bram Moolenaar <Bram@vim.org>
parents: 26338
diff changeset
1735
13cce5c82c9a patch 8.2.3706: text property highlighting is used on Tab
Bram Moolenaar <Bram@vim.org>
parents: 26338
diff changeset
1736 call StopVimInTerminal(buf)
13cce5c82c9a patch 8.2.3706: text property highlighting is used on Tab
Bram Moolenaar <Bram@vim.org>
parents: 26338
diff changeset
1737 call delete('XscriptPropAfterTab')
13cce5c82c9a patch 8.2.3706: text property highlighting is used on Tab
Bram Moolenaar <Bram@vim.org>
parents: 26338
diff changeset
1738 endfunc
13cce5c82c9a patch 8.2.3706: text property highlighting is used on Tab
Bram Moolenaar <Bram@vim.org>
parents: 26338
diff changeset
1739
26384
e624b4ddbdf0 patch 8.2.3723: when using 'linebreak' a text property starts too early
Bram Moolenaar <Bram@vim.org>
parents: 26350
diff changeset
1740 func Test_prop_after_linebreak()
e624b4ddbdf0 patch 8.2.3723: when using 'linebreak' a text property starts too early
Bram Moolenaar <Bram@vim.org>
parents: 26350
diff changeset
1741 CheckRunVimInTerminal
e624b4ddbdf0 patch 8.2.3723: when using 'linebreak' a text property starts too early
Bram Moolenaar <Bram@vim.org>
parents: 26350
diff changeset
1742
e624b4ddbdf0 patch 8.2.3723: when using 'linebreak' a text property starts too early
Bram Moolenaar <Bram@vim.org>
parents: 26350
diff changeset
1743 let lines =<< trim END
e624b4ddbdf0 patch 8.2.3723: when using 'linebreak' a text property starts too early
Bram Moolenaar <Bram@vim.org>
parents: 26350
diff changeset
1744 set linebreak wrap
e624b4ddbdf0 patch 8.2.3723: when using 'linebreak' a text property starts too early
Bram Moolenaar <Bram@vim.org>
parents: 26350
diff changeset
1745 call printf('%s+(%s)', 'x'->repeat(&columns / 2), 'x'->repeat(&columns / 2))->setline(1)
e624b4ddbdf0 patch 8.2.3723: when using 'linebreak' a text property starts too early
Bram Moolenaar <Bram@vim.org>
parents: 26350
diff changeset
1746 call prop_type_add('test', #{highlight: 'ErrorMsg'})
e624b4ddbdf0 patch 8.2.3723: when using 'linebreak' a text property starts too early
Bram Moolenaar <Bram@vim.org>
parents: 26350
diff changeset
1747 call prop_add(1, (&columns / 2) + 2, #{length: 1, type: 'test'})
e624b4ddbdf0 patch 8.2.3723: when using 'linebreak' a text property starts too early
Bram Moolenaar <Bram@vim.org>
parents: 26350
diff changeset
1748 END
e624b4ddbdf0 patch 8.2.3723: when using 'linebreak' a text property starts too early
Bram Moolenaar <Bram@vim.org>
parents: 26350
diff changeset
1749 call writefile(lines, 'XscriptPropAfterLinebreak')
e624b4ddbdf0 patch 8.2.3723: when using 'linebreak' a text property starts too early
Bram Moolenaar <Bram@vim.org>
parents: 26350
diff changeset
1750 let buf = RunVimInTerminal('-S XscriptPropAfterLinebreak', #{rows: 10})
e624b4ddbdf0 patch 8.2.3723: when using 'linebreak' a text property starts too early
Bram Moolenaar <Bram@vim.org>
parents: 26350
diff changeset
1751 call VerifyScreenDump(buf, 'Test_prop_after_linebreak', {})
e624b4ddbdf0 patch 8.2.3723: when using 'linebreak' a text property starts too early
Bram Moolenaar <Bram@vim.org>
parents: 26350
diff changeset
1752
e624b4ddbdf0 patch 8.2.3723: when using 'linebreak' a text property starts too early
Bram Moolenaar <Bram@vim.org>
parents: 26350
diff changeset
1753 call StopVimInTerminal(buf)
e624b4ddbdf0 patch 8.2.3723: when using 'linebreak' a text property starts too early
Bram Moolenaar <Bram@vim.org>
parents: 26350
diff changeset
1754 call delete('XscriptPropAfterLinebreak')
e624b4ddbdf0 patch 8.2.3723: when using 'linebreak' a text property starts too early
Bram Moolenaar <Bram@vim.org>
parents: 26350
diff changeset
1755 endfunc
e624b4ddbdf0 patch 8.2.3723: when using 'linebreak' a text property starts too early
Bram Moolenaar <Bram@vim.org>
parents: 26350
diff changeset
1756
25392
b427a26b0210 patch 8.2.3233: prop_list() and prop_find() do not indicate the buffer
Bram Moolenaar <Bram@vim.org>
parents: 25198
diff changeset
1757 " Buffer number of 0 should be ignored, as if the parameter wasn't passed.
b427a26b0210 patch 8.2.3233: prop_list() and prop_find() do not indicate the buffer
Bram Moolenaar <Bram@vim.org>
parents: 25198
diff changeset
1758 def Test_prop_bufnr_zero()
b427a26b0210 patch 8.2.3233: prop_list() and prop_find() do not indicate the buffer
Bram Moolenaar <Bram@vim.org>
parents: 25198
diff changeset
1759 new
b427a26b0210 patch 8.2.3233: prop_list() and prop_find() do not indicate the buffer
Bram Moolenaar <Bram@vim.org>
parents: 25198
diff changeset
1760 try
b427a26b0210 patch 8.2.3233: prop_list() and prop_find() do not indicate the buffer
Bram Moolenaar <Bram@vim.org>
parents: 25198
diff changeset
1761 var bufnr = bufnr('')
b427a26b0210 patch 8.2.3233: prop_list() and prop_find() do not indicate the buffer
Bram Moolenaar <Bram@vim.org>
parents: 25198
diff changeset
1762 setline(1, 'hello')
b427a26b0210 patch 8.2.3233: prop_list() and prop_find() do not indicate the buffer
Bram Moolenaar <Bram@vim.org>
parents: 25198
diff changeset
1763 prop_type_add('bufnr-global', {highlight: 'ErrorMsg'})
b427a26b0210 patch 8.2.3233: prop_list() and prop_find() do not indicate the buffer
Bram Moolenaar <Bram@vim.org>
parents: 25198
diff changeset
1764 prop_type_add('bufnr-buffer', {highlight: 'StatusLine', bufnr: bufnr})
b427a26b0210 patch 8.2.3233: prop_list() and prop_find() do not indicate the buffer
Bram Moolenaar <Bram@vim.org>
parents: 25198
diff changeset
1765
b427a26b0210 patch 8.2.3233: prop_list() and prop_find() do not indicate the buffer
Bram Moolenaar <Bram@vim.org>
parents: 25198
diff changeset
1766 prop_add(1, 1, {type: 'bufnr-global', length: 1})
b427a26b0210 patch 8.2.3233: prop_list() and prop_find() do not indicate the buffer
Bram Moolenaar <Bram@vim.org>
parents: 25198
diff changeset
1767 prop_add(1, 2, {type: 'bufnr-buffer', length: 1})
b427a26b0210 patch 8.2.3233: prop_list() and prop_find() do not indicate the buffer
Bram Moolenaar <Bram@vim.org>
parents: 25198
diff changeset
1768
b427a26b0210 patch 8.2.3233: prop_list() and prop_find() do not indicate the buffer
Bram Moolenaar <Bram@vim.org>
parents: 25198
diff changeset
1769 var list = prop_list(1)
b427a26b0210 patch 8.2.3233: prop_list() and prop_find() do not indicate the buffer
Bram Moolenaar <Bram@vim.org>
parents: 25198
diff changeset
1770 assert_equal([
b427a26b0210 patch 8.2.3233: prop_list() and prop_find() do not indicate the buffer
Bram Moolenaar <Bram@vim.org>
parents: 25198
diff changeset
1771 {id: 0, col: 1, type_bufnr: 0, end: 1, type: 'bufnr-global', length: 1, start: 1},
b427a26b0210 patch 8.2.3233: prop_list() and prop_find() do not indicate the buffer
Bram Moolenaar <Bram@vim.org>
parents: 25198
diff changeset
1772 {id: 0, col: 2, type_bufnr: bufnr, end: 1, type: 'bufnr-buffer', length: 1, start: 1},
b427a26b0210 patch 8.2.3233: prop_list() and prop_find() do not indicate the buffer
Bram Moolenaar <Bram@vim.org>
parents: 25198
diff changeset
1773 ], list)
b427a26b0210 patch 8.2.3233: prop_list() and prop_find() do not indicate the buffer
Bram Moolenaar <Bram@vim.org>
parents: 25198
diff changeset
1774
b427a26b0210 patch 8.2.3233: prop_list() and prop_find() do not indicate the buffer
Bram Moolenaar <Bram@vim.org>
parents: 25198
diff changeset
1775 assert_equal(
b427a26b0210 patch 8.2.3233: prop_list() and prop_find() do not indicate the buffer
Bram Moolenaar <Bram@vim.org>
parents: 25198
diff changeset
1776 {highlight: 'ErrorMsg', end_incl: 0, start_incl: 0, priority: 0, combine: 1},
b427a26b0210 patch 8.2.3233: prop_list() and prop_find() do not indicate the buffer
Bram Moolenaar <Bram@vim.org>
parents: 25198
diff changeset
1777 prop_type_get('bufnr-global', {bufnr: list[0].type_bufnr}))
b427a26b0210 patch 8.2.3233: prop_list() and prop_find() do not indicate the buffer
Bram Moolenaar <Bram@vim.org>
parents: 25198
diff changeset
1778
b427a26b0210 patch 8.2.3233: prop_list() and prop_find() do not indicate the buffer
Bram Moolenaar <Bram@vim.org>
parents: 25198
diff changeset
1779 assert_equal(
b427a26b0210 patch 8.2.3233: prop_list() and prop_find() do not indicate the buffer
Bram Moolenaar <Bram@vim.org>
parents: 25198
diff changeset
1780 {highlight: 'StatusLine', end_incl: 0, start_incl: 0, priority: 0, bufnr: bufnr, combine: 1},
b427a26b0210 patch 8.2.3233: prop_list() and prop_find() do not indicate the buffer
Bram Moolenaar <Bram@vim.org>
parents: 25198
diff changeset
1781 prop_type_get('bufnr-buffer', {bufnr: list[1].type_bufnr}))
b427a26b0210 patch 8.2.3233: prop_list() and prop_find() do not indicate the buffer
Bram Moolenaar <Bram@vim.org>
parents: 25198
diff changeset
1782 finally
b427a26b0210 patch 8.2.3233: prop_list() and prop_find() do not indicate the buffer
Bram Moolenaar <Bram@vim.org>
parents: 25198
diff changeset
1783 bwipe!
b427a26b0210 patch 8.2.3233: prop_list() and prop_find() do not indicate the buffer
Bram Moolenaar <Bram@vim.org>
parents: 25198
diff changeset
1784 prop_type_delete('bufnr-global')
b427a26b0210 patch 8.2.3233: prop_list() and prop_find() do not indicate the buffer
Bram Moolenaar <Bram@vim.org>
parents: 25198
diff changeset
1785 endtry
b427a26b0210 patch 8.2.3233: prop_list() and prop_find() do not indicate the buffer
Bram Moolenaar <Bram@vim.org>
parents: 25198
diff changeset
1786 enddef
b427a26b0210 patch 8.2.3233: prop_list() and prop_find() do not indicate the buffer
Bram Moolenaar <Bram@vim.org>
parents: 25198
diff changeset
1787
26242
685206b54ecf patch 8.2.3652: can only get text properties one line at a time
Bram Moolenaar <Bram@vim.org>
parents: 25674
diff changeset
1788 " Tests for the prop_list() function
685206b54ecf patch 8.2.3652: can only get text properties one line at a time
Bram Moolenaar <Bram@vim.org>
parents: 25674
diff changeset
1789 func Test_prop_list()
685206b54ecf patch 8.2.3652: can only get text properties one line at a time
Bram Moolenaar <Bram@vim.org>
parents: 25674
diff changeset
1790 let lines =<< trim END
685206b54ecf patch 8.2.3652: can only get text properties one line at a time
Bram Moolenaar <Bram@vim.org>
parents: 25674
diff changeset
1791 new
27457
4c16acb2525f patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 26384
diff changeset
1792 call g:AddPropTypes()
26242
685206b54ecf patch 8.2.3652: can only get text properties one line at a time
Bram Moolenaar <Bram@vim.org>
parents: 25674
diff changeset
1793 call setline(1, repeat([repeat('a', 60)], 10))
685206b54ecf patch 8.2.3652: can only get text properties one line at a time
Bram Moolenaar <Bram@vim.org>
parents: 25674
diff changeset
1794 call prop_add(1, 4, {'type': 'one', 'id': 5, 'end_col': 6})
685206b54ecf patch 8.2.3652: can only get text properties one line at a time
Bram Moolenaar <Bram@vim.org>
parents: 25674
diff changeset
1795 call prop_add(1, 5, {'type': 'two', 'id': 10, 'end_col': 7})
685206b54ecf patch 8.2.3652: can only get text properties one line at a time
Bram Moolenaar <Bram@vim.org>
parents: 25674
diff changeset
1796 call prop_add(3, 12, {'type': 'one', 'id': 20, 'end_col': 14})
685206b54ecf patch 8.2.3652: can only get text properties one line at a time
Bram Moolenaar <Bram@vim.org>
parents: 25674
diff changeset
1797 call prop_add(3, 13, {'type': 'two', 'id': 10, 'end_col': 15})
685206b54ecf patch 8.2.3652: can only get text properties one line at a time
Bram Moolenaar <Bram@vim.org>
parents: 25674
diff changeset
1798 call prop_add(5, 20, {'type': 'one', 'id': 10, 'end_col': 22})
685206b54ecf patch 8.2.3652: can only get text properties one line at a time
Bram Moolenaar <Bram@vim.org>
parents: 25674
diff changeset
1799 call prop_add(5, 21, {'type': 'two', 'id': 20, 'end_col': 23})
685206b54ecf patch 8.2.3652: can only get text properties one line at a time
Bram Moolenaar <Bram@vim.org>
parents: 25674
diff changeset
1800 call assert_equal([
685206b54ecf patch 8.2.3652: can only get text properties one line at a time
Bram Moolenaar <Bram@vim.org>
parents: 25674
diff changeset
1801 \ {'id': 5, 'col': 4, 'type_bufnr': 0, 'end': 1,
685206b54ecf patch 8.2.3652: can only get text properties one line at a time
Bram Moolenaar <Bram@vim.org>
parents: 25674
diff changeset
1802 \ 'type': 'one', 'length': 2, 'start': 1},
685206b54ecf patch 8.2.3652: can only get text properties one line at a time
Bram Moolenaar <Bram@vim.org>
parents: 25674
diff changeset
1803 \ {'id': 10, 'col': 5, 'type_bufnr': 0, 'end': 1,
685206b54ecf patch 8.2.3652: can only get text properties one line at a time
Bram Moolenaar <Bram@vim.org>
parents: 25674
diff changeset
1804 \ 'type': 'two', 'length': 2, 'start': 1}], prop_list(1))
685206b54ecf patch 8.2.3652: can only get text properties one line at a time
Bram Moolenaar <Bram@vim.org>
parents: 25674
diff changeset
1805 #" text properties between a few lines
685206b54ecf patch 8.2.3652: can only get text properties one line at a time
Bram Moolenaar <Bram@vim.org>
parents: 25674
diff changeset
1806 call assert_equal([
685206b54ecf patch 8.2.3652: can only get text properties one line at a time
Bram Moolenaar <Bram@vim.org>
parents: 25674
diff changeset
1807 \ {'lnum': 3, 'id': 20, 'col': 12, 'type_bufnr': 0, 'end': 1,
685206b54ecf patch 8.2.3652: can only get text properties one line at a time
Bram Moolenaar <Bram@vim.org>
parents: 25674
diff changeset
1808 \ 'type': 'one', 'length': 2, 'start': 1},
685206b54ecf patch 8.2.3652: can only get text properties one line at a time
Bram Moolenaar <Bram@vim.org>
parents: 25674
diff changeset
1809 \ {'lnum': 3, 'id': 10, 'col': 13, 'type_bufnr': 0, 'end': 1,
685206b54ecf patch 8.2.3652: can only get text properties one line at a time
Bram Moolenaar <Bram@vim.org>
parents: 25674
diff changeset
1810 \ 'type': 'two', 'length': 2, 'start': 1},
685206b54ecf patch 8.2.3652: can only get text properties one line at a time
Bram Moolenaar <Bram@vim.org>
parents: 25674
diff changeset
1811 \ {'lnum': 5, 'id': 10, 'col': 20, 'type_bufnr': 0, 'end': 1,
685206b54ecf patch 8.2.3652: can only get text properties one line at a time
Bram Moolenaar <Bram@vim.org>
parents: 25674
diff changeset
1812 \ 'type': 'one', 'length': 2, 'start': 1},
685206b54ecf patch 8.2.3652: can only get text properties one line at a time
Bram Moolenaar <Bram@vim.org>
parents: 25674
diff changeset
1813 \ {'lnum': 5, 'id': 20, 'col': 21, 'type_bufnr': 0, 'end': 1,
685206b54ecf patch 8.2.3652: can only get text properties one line at a time
Bram Moolenaar <Bram@vim.org>
parents: 25674
diff changeset
1814 \ 'type': 'two', 'length': 2, 'start': 1}],
685206b54ecf patch 8.2.3652: can only get text properties one line at a time
Bram Moolenaar <Bram@vim.org>
parents: 25674
diff changeset
1815 \ prop_list(2, {'end_lnum': 5}))
685206b54ecf patch 8.2.3652: can only get text properties one line at a time
Bram Moolenaar <Bram@vim.org>
parents: 25674
diff changeset
1816 #" text properties across all the lines
685206b54ecf patch 8.2.3652: can only get text properties one line at a time
Bram Moolenaar <Bram@vim.org>
parents: 25674
diff changeset
1817 call assert_equal([
685206b54ecf patch 8.2.3652: can only get text properties one line at a time
Bram Moolenaar <Bram@vim.org>
parents: 25674
diff changeset
1818 \ {'lnum': 1, 'id': 5, 'col': 4, 'type_bufnr': 0, 'end': 1,
685206b54ecf patch 8.2.3652: can only get text properties one line at a time
Bram Moolenaar <Bram@vim.org>
parents: 25674
diff changeset
1819 \ 'type': 'one', 'length': 2, 'start': 1},
685206b54ecf patch 8.2.3652: can only get text properties one line at a time
Bram Moolenaar <Bram@vim.org>
parents: 25674
diff changeset
1820 \ {'lnum': 3, 'id': 20, 'col': 12, 'type_bufnr': 0, 'end': 1,
685206b54ecf patch 8.2.3652: can only get text properties one line at a time
Bram Moolenaar <Bram@vim.org>
parents: 25674
diff changeset
1821 \ 'type': 'one', 'length': 2, 'start': 1},
685206b54ecf patch 8.2.3652: can only get text properties one line at a time
Bram Moolenaar <Bram@vim.org>
parents: 25674
diff changeset
1822 \ {'lnum': 5, 'id': 10, 'col': 20, 'type_bufnr': 0, 'end': 1,
685206b54ecf patch 8.2.3652: can only get text properties one line at a time
Bram Moolenaar <Bram@vim.org>
parents: 25674
diff changeset
1823 \ 'type': 'one', 'length': 2, 'start': 1}],
685206b54ecf patch 8.2.3652: can only get text properties one line at a time
Bram Moolenaar <Bram@vim.org>
parents: 25674
diff changeset
1824 \ prop_list(1, {'types': ['one'], 'end_lnum': -1}))
685206b54ecf patch 8.2.3652: can only get text properties one line at a time
Bram Moolenaar <Bram@vim.org>
parents: 25674
diff changeset
1825 #" text properties with the specified identifier
685206b54ecf patch 8.2.3652: can only get text properties one line at a time
Bram Moolenaar <Bram@vim.org>
parents: 25674
diff changeset
1826 call assert_equal([
685206b54ecf patch 8.2.3652: can only get text properties one line at a time
Bram Moolenaar <Bram@vim.org>
parents: 25674
diff changeset
1827 \ {'lnum': 3, 'id': 20, 'col': 12, 'type_bufnr': 0, 'end': 1,
685206b54ecf patch 8.2.3652: can only get text properties one line at a time
Bram Moolenaar <Bram@vim.org>
parents: 25674
diff changeset
1828 \ 'type': 'one', 'length': 2, 'start': 1},
685206b54ecf patch 8.2.3652: can only get text properties one line at a time
Bram Moolenaar <Bram@vim.org>
parents: 25674
diff changeset
1829 \ {'lnum': 5, 'id': 20, 'col': 21, 'type_bufnr': 0, 'end': 1,
685206b54ecf patch 8.2.3652: can only get text properties one line at a time
Bram Moolenaar <Bram@vim.org>
parents: 25674
diff changeset
1830 \ 'type': 'two', 'length': 2, 'start': 1}],
685206b54ecf patch 8.2.3652: can only get text properties one line at a time
Bram Moolenaar <Bram@vim.org>
parents: 25674
diff changeset
1831 \ prop_list(1, {'ids': [20], 'end_lnum': 10}))
685206b54ecf patch 8.2.3652: can only get text properties one line at a time
Bram Moolenaar <Bram@vim.org>
parents: 25674
diff changeset
1832 #" text properties of the specified type and id
685206b54ecf patch 8.2.3652: can only get text properties one line at a time
Bram Moolenaar <Bram@vim.org>
parents: 25674
diff changeset
1833 call assert_equal([
685206b54ecf patch 8.2.3652: can only get text properties one line at a time
Bram Moolenaar <Bram@vim.org>
parents: 25674
diff changeset
1834 \ {'lnum': 1, 'id': 10, 'col': 5, 'type_bufnr': 0, 'end': 1,
685206b54ecf patch 8.2.3652: can only get text properties one line at a time
Bram Moolenaar <Bram@vim.org>
parents: 25674
diff changeset
1835 \ 'type': 'two', 'length': 2, 'start': 1},
685206b54ecf patch 8.2.3652: can only get text properties one line at a time
Bram Moolenaar <Bram@vim.org>
parents: 25674
diff changeset
1836 \ {'lnum': 3, 'id': 10, 'col': 13, 'type_bufnr': 0, 'end': 1,
685206b54ecf patch 8.2.3652: can only get text properties one line at a time
Bram Moolenaar <Bram@vim.org>
parents: 25674
diff changeset
1837 \ 'type': 'two', 'length': 2, 'start': 1}],
685206b54ecf patch 8.2.3652: can only get text properties one line at a time
Bram Moolenaar <Bram@vim.org>
parents: 25674
diff changeset
1838 \ prop_list(1, {'types': ['two'], 'ids': [10], 'end_lnum': 20}))
685206b54ecf patch 8.2.3652: can only get text properties one line at a time
Bram Moolenaar <Bram@vim.org>
parents: 25674
diff changeset
1839 call assert_equal([], prop_list(1, {'ids': [40, 50], 'end_lnum': 10}))
685206b54ecf patch 8.2.3652: can only get text properties one line at a time
Bram Moolenaar <Bram@vim.org>
parents: 25674
diff changeset
1840 call assert_equal([], prop_list(6, {'end_lnum': 10}))
685206b54ecf patch 8.2.3652: can only get text properties one line at a time
Bram Moolenaar <Bram@vim.org>
parents: 25674
diff changeset
1841 call assert_equal([], prop_list(2, {'end_lnum': 2}))
685206b54ecf patch 8.2.3652: can only get text properties one line at a time
Bram Moolenaar <Bram@vim.org>
parents: 25674
diff changeset
1842 #" error cases
685206b54ecf patch 8.2.3652: can only get text properties one line at a time
Bram Moolenaar <Bram@vim.org>
parents: 25674
diff changeset
1843 call assert_fails("echo prop_list(1, {'end_lnum': -20})", 'E16:')
685206b54ecf patch 8.2.3652: can only get text properties one line at a time
Bram Moolenaar <Bram@vim.org>
parents: 25674
diff changeset
1844 call assert_fails("echo prop_list(4, {'end_lnum': 2})", 'E16:')
685206b54ecf patch 8.2.3652: can only get text properties one line at a time
Bram Moolenaar <Bram@vim.org>
parents: 25674
diff changeset
1845 call assert_fails("echo prop_list(1, {'end_lnum': '$'})", 'E889:')
685206b54ecf patch 8.2.3652: can only get text properties one line at a time
Bram Moolenaar <Bram@vim.org>
parents: 25674
diff changeset
1846 call assert_fails("echo prop_list(1, {'types': ['blue'], 'end_lnum': 10})",
685206b54ecf patch 8.2.3652: can only get text properties one line at a time
Bram Moolenaar <Bram@vim.org>
parents: 25674
diff changeset
1847 \ 'E971:')
685206b54ecf patch 8.2.3652: can only get text properties one line at a time
Bram Moolenaar <Bram@vim.org>
parents: 25674
diff changeset
1848 call assert_fails("echo prop_list(1, {'types': ['one', 'blue'],
685206b54ecf patch 8.2.3652: can only get text properties one line at a time
Bram Moolenaar <Bram@vim.org>
parents: 25674
diff changeset
1849 \ 'end_lnum': 10})", 'E971:')
685206b54ecf patch 8.2.3652: can only get text properties one line at a time
Bram Moolenaar <Bram@vim.org>
parents: 25674
diff changeset
1850 call assert_fails("echo prop_list(1, {'types': ['one', 10],
685206b54ecf patch 8.2.3652: can only get text properties one line at a time
Bram Moolenaar <Bram@vim.org>
parents: 25674
diff changeset
1851 \ 'end_lnum': 10})", 'E928:')
685206b54ecf patch 8.2.3652: can only get text properties one line at a time
Bram Moolenaar <Bram@vim.org>
parents: 25674
diff changeset
1852 call assert_fails("echo prop_list(1, {'types': ['']})", 'E971:')
685206b54ecf patch 8.2.3652: can only get text properties one line at a time
Bram Moolenaar <Bram@vim.org>
parents: 25674
diff changeset
1853 call assert_equal([], prop_list(2, {'types': []}))
685206b54ecf patch 8.2.3652: can only get text properties one line at a time
Bram Moolenaar <Bram@vim.org>
parents: 25674
diff changeset
1854 call assert_equal([], prop_list(2, {'types': test_null_list()}))
685206b54ecf patch 8.2.3652: can only get text properties one line at a time
Bram Moolenaar <Bram@vim.org>
parents: 25674
diff changeset
1855 call assert_fails("call prop_list(1, {'types': {}})", 'E714:')
685206b54ecf patch 8.2.3652: can only get text properties one line at a time
Bram Moolenaar <Bram@vim.org>
parents: 25674
diff changeset
1856 call assert_fails("call prop_list(1, {'types': 'one'})", 'E714:')
685206b54ecf patch 8.2.3652: can only get text properties one line at a time
Bram Moolenaar <Bram@vim.org>
parents: 25674
diff changeset
1857 call assert_equal([], prop_list(2, {'types': ['one'],
685206b54ecf patch 8.2.3652: can only get text properties one line at a time
Bram Moolenaar <Bram@vim.org>
parents: 25674
diff changeset
1858 \ 'ids': test_null_list()}))
685206b54ecf patch 8.2.3652: can only get text properties one line at a time
Bram Moolenaar <Bram@vim.org>
parents: 25674
diff changeset
1859 call assert_equal([], prop_list(2, {'types': ['one'], 'ids': []}))
685206b54ecf patch 8.2.3652: can only get text properties one line at a time
Bram Moolenaar <Bram@vim.org>
parents: 25674
diff changeset
1860 call assert_fails("call prop_list(1, {'types': ['one'], 'ids': {}})",
685206b54ecf patch 8.2.3652: can only get text properties one line at a time
Bram Moolenaar <Bram@vim.org>
parents: 25674
diff changeset
1861 \ 'E714:')
685206b54ecf patch 8.2.3652: can only get text properties one line at a time
Bram Moolenaar <Bram@vim.org>
parents: 25674
diff changeset
1862 call assert_fails("call prop_list(1, {'types': ['one'], 'ids': 10})",
685206b54ecf patch 8.2.3652: can only get text properties one line at a time
Bram Moolenaar <Bram@vim.org>
parents: 25674
diff changeset
1863 \ 'E714:')
685206b54ecf patch 8.2.3652: can only get text properties one line at a time
Bram Moolenaar <Bram@vim.org>
parents: 25674
diff changeset
1864 call assert_fails("call prop_list(1, {'types': ['one'], 'ids': [[]]})",
685206b54ecf patch 8.2.3652: can only get text properties one line at a time
Bram Moolenaar <Bram@vim.org>
parents: 25674
diff changeset
1865 \ 'E745:')
685206b54ecf patch 8.2.3652: can only get text properties one line at a time
Bram Moolenaar <Bram@vim.org>
parents: 25674
diff changeset
1866 call assert_fails("call prop_list(1, {'types': ['one'], 'ids': [10, []]})",
685206b54ecf patch 8.2.3652: can only get text properties one line at a time
Bram Moolenaar <Bram@vim.org>
parents: 25674
diff changeset
1867 \ 'E745:')
25392
b427a26b0210 patch 8.2.3233: prop_list() and prop_find() do not indicate the buffer
Bram Moolenaar <Bram@vim.org>
parents: 25198
diff changeset
1868
26242
685206b54ecf patch 8.2.3652: can only get text properties one line at a time
Bram Moolenaar <Bram@vim.org>
parents: 25674
diff changeset
1869 #" get text properties from a non-current buffer
685206b54ecf patch 8.2.3652: can only get text properties one line at a time
Bram Moolenaar <Bram@vim.org>
parents: 25674
diff changeset
1870 wincmd w
685206b54ecf patch 8.2.3652: can only get text properties one line at a time
Bram Moolenaar <Bram@vim.org>
parents: 25674
diff changeset
1871 call assert_equal([
685206b54ecf patch 8.2.3652: can only get text properties one line at a time
Bram Moolenaar <Bram@vim.org>
parents: 25674
diff changeset
1872 \ {'lnum': 1, 'id': 5, 'col': 4, 'type_bufnr': 0, 'end': 1,
685206b54ecf patch 8.2.3652: can only get text properties one line at a time
Bram Moolenaar <Bram@vim.org>
parents: 25674
diff changeset
1873 \ 'type': 'one', 'length': 2, 'start': 1},
685206b54ecf patch 8.2.3652: can only get text properties one line at a time
Bram Moolenaar <Bram@vim.org>
parents: 25674
diff changeset
1874 \ {'lnum': 1, 'id': 10, 'col': 5, 'type_bufnr': 0, 'end': 1,
685206b54ecf patch 8.2.3652: can only get text properties one line at a time
Bram Moolenaar <Bram@vim.org>
parents: 25674
diff changeset
1875 \ 'type': 'two', 'length': 2, 'start': 1},
685206b54ecf patch 8.2.3652: can only get text properties one line at a time
Bram Moolenaar <Bram@vim.org>
parents: 25674
diff changeset
1876 \ {'lnum': 3, 'id': 20, 'col': 12, 'type_bufnr': 0, 'end': 1,
685206b54ecf patch 8.2.3652: can only get text properties one line at a time
Bram Moolenaar <Bram@vim.org>
parents: 25674
diff changeset
1877 \ 'type': 'one', 'length': 2, 'start': 1},
685206b54ecf patch 8.2.3652: can only get text properties one line at a time
Bram Moolenaar <Bram@vim.org>
parents: 25674
diff changeset
1878 \ {'lnum': 3, 'id': 10, 'col': 13, 'type_bufnr': 0, 'end': 1,
685206b54ecf patch 8.2.3652: can only get text properties one line at a time
Bram Moolenaar <Bram@vim.org>
parents: 25674
diff changeset
1879 \ 'type': 'two', 'length': 2, 'start': 1}],
685206b54ecf patch 8.2.3652: can only get text properties one line at a time
Bram Moolenaar <Bram@vim.org>
parents: 25674
diff changeset
1880 \ prop_list(1, {'bufnr': winbufnr(1), 'end_lnum': 4}))
685206b54ecf patch 8.2.3652: can only get text properties one line at a time
Bram Moolenaar <Bram@vim.org>
parents: 25674
diff changeset
1881 wincmd w
685206b54ecf patch 8.2.3652: can only get text properties one line at a time
Bram Moolenaar <Bram@vim.org>
parents: 25674
diff changeset
1882
685206b54ecf patch 8.2.3652: can only get text properties one line at a time
Bram Moolenaar <Bram@vim.org>
parents: 25674
diff changeset
1883 #" get text properties after clearing all the properties
685206b54ecf patch 8.2.3652: can only get text properties one line at a time
Bram Moolenaar <Bram@vim.org>
parents: 25674
diff changeset
1884 call prop_clear(1, line('$'))
685206b54ecf patch 8.2.3652: can only get text properties one line at a time
Bram Moolenaar <Bram@vim.org>
parents: 25674
diff changeset
1885 call assert_equal([], prop_list(1, {'end_lnum': 10}))
685206b54ecf patch 8.2.3652: can only get text properties one line at a time
Bram Moolenaar <Bram@vim.org>
parents: 25674
diff changeset
1886
685206b54ecf patch 8.2.3652: can only get text properties one line at a time
Bram Moolenaar <Bram@vim.org>
parents: 25674
diff changeset
1887 call prop_add(2, 4, {'type': 'one', 'id': 5, 'end_col': 6})
685206b54ecf patch 8.2.3652: can only get text properties one line at a time
Bram Moolenaar <Bram@vim.org>
parents: 25674
diff changeset
1888 call prop_add(2, 4, {'type': 'two', 'id': 10, 'end_col': 6})
685206b54ecf patch 8.2.3652: can only get text properties one line at a time
Bram Moolenaar <Bram@vim.org>
parents: 25674
diff changeset
1889 call prop_add(2, 4, {'type': 'three', 'id': 15, 'end_col': 6})
685206b54ecf patch 8.2.3652: can only get text properties one line at a time
Bram Moolenaar <Bram@vim.org>
parents: 25674
diff changeset
1890 #" get text properties with a list of types
685206b54ecf patch 8.2.3652: can only get text properties one line at a time
Bram Moolenaar <Bram@vim.org>
parents: 25674
diff changeset
1891 call assert_equal([
685206b54ecf patch 8.2.3652: can only get text properties one line at a time
Bram Moolenaar <Bram@vim.org>
parents: 25674
diff changeset
1892 \ {'id': 10, 'col': 4, 'type_bufnr': 0, 'end': 1,
685206b54ecf patch 8.2.3652: can only get text properties one line at a time
Bram Moolenaar <Bram@vim.org>
parents: 25674
diff changeset
1893 \ 'type': 'two', 'length': 2, 'start': 1},
685206b54ecf patch 8.2.3652: can only get text properties one line at a time
Bram Moolenaar <Bram@vim.org>
parents: 25674
diff changeset
1894 \ {'id': 5, 'col': 4, 'type_bufnr': 0, 'end': 1,
685206b54ecf patch 8.2.3652: can only get text properties one line at a time
Bram Moolenaar <Bram@vim.org>
parents: 25674
diff changeset
1895 \ 'type': 'one', 'length': 2, 'start': 1}],
685206b54ecf patch 8.2.3652: can only get text properties one line at a time
Bram Moolenaar <Bram@vim.org>
parents: 25674
diff changeset
1896 \ prop_list(2, {'types': ['one', 'two']}))
685206b54ecf patch 8.2.3652: can only get text properties one line at a time
Bram Moolenaar <Bram@vim.org>
parents: 25674
diff changeset
1897 call assert_equal([
685206b54ecf patch 8.2.3652: can only get text properties one line at a time
Bram Moolenaar <Bram@vim.org>
parents: 25674
diff changeset
1898 \ {'id': 15, 'col': 4, 'type_bufnr': 0, 'end': 1,
685206b54ecf patch 8.2.3652: can only get text properties one line at a time
Bram Moolenaar <Bram@vim.org>
parents: 25674
diff changeset
1899 \ 'type': 'three', 'length': 2, 'start': 1},
685206b54ecf patch 8.2.3652: can only get text properties one line at a time
Bram Moolenaar <Bram@vim.org>
parents: 25674
diff changeset
1900 \ {'id': 5, 'col': 4, 'type_bufnr': 0, 'end': 1,
685206b54ecf patch 8.2.3652: can only get text properties one line at a time
Bram Moolenaar <Bram@vim.org>
parents: 25674
diff changeset
1901 \ 'type': 'one', 'length': 2, 'start': 1}],
685206b54ecf patch 8.2.3652: can only get text properties one line at a time
Bram Moolenaar <Bram@vim.org>
parents: 25674
diff changeset
1902 \ prop_list(2, {'types': ['one', 'three']}))
685206b54ecf patch 8.2.3652: can only get text properties one line at a time
Bram Moolenaar <Bram@vim.org>
parents: 25674
diff changeset
1903 #" get text properties with a list of identifiers
685206b54ecf patch 8.2.3652: can only get text properties one line at a time
Bram Moolenaar <Bram@vim.org>
parents: 25674
diff changeset
1904 call assert_equal([
685206b54ecf patch 8.2.3652: can only get text properties one line at a time
Bram Moolenaar <Bram@vim.org>
parents: 25674
diff changeset
1905 \ {'id': 10, 'col': 4, 'type_bufnr': 0, 'end': 1,
685206b54ecf patch 8.2.3652: can only get text properties one line at a time
Bram Moolenaar <Bram@vim.org>
parents: 25674
diff changeset
1906 \ 'type': 'two', 'length': 2, 'start': 1},
685206b54ecf patch 8.2.3652: can only get text properties one line at a time
Bram Moolenaar <Bram@vim.org>
parents: 25674
diff changeset
1907 \ {'id': 5, 'col': 4, 'type_bufnr': 0, 'end': 1,
685206b54ecf patch 8.2.3652: can only get text properties one line at a time
Bram Moolenaar <Bram@vim.org>
parents: 25674
diff changeset
1908 \ 'type': 'one', 'length': 2, 'start': 1}],
685206b54ecf patch 8.2.3652: can only get text properties one line at a time
Bram Moolenaar <Bram@vim.org>
parents: 25674
diff changeset
1909 \ prop_list(2, {'ids': [5, 10, 20]}))
685206b54ecf patch 8.2.3652: can only get text properties one line at a time
Bram Moolenaar <Bram@vim.org>
parents: 25674
diff changeset
1910 call prop_clear(1, line('$'))
685206b54ecf patch 8.2.3652: can only get text properties one line at a time
Bram Moolenaar <Bram@vim.org>
parents: 25674
diff changeset
1911 call assert_equal([], prop_list(2, {'types': ['one', 'two']}))
685206b54ecf patch 8.2.3652: can only get text properties one line at a time
Bram Moolenaar <Bram@vim.org>
parents: 25674
diff changeset
1912 call assert_equal([], prop_list(2, {'ids': [5, 10, 20]}))
685206b54ecf patch 8.2.3652: can only get text properties one line at a time
Bram Moolenaar <Bram@vim.org>
parents: 25674
diff changeset
1913
685206b54ecf patch 8.2.3652: can only get text properties one line at a time
Bram Moolenaar <Bram@vim.org>
parents: 25674
diff changeset
1914 #" get text properties from a hidden buffer
685206b54ecf patch 8.2.3652: can only get text properties one line at a time
Bram Moolenaar <Bram@vim.org>
parents: 25674
diff changeset
1915 edit! Xaaa
685206b54ecf patch 8.2.3652: can only get text properties one line at a time
Bram Moolenaar <Bram@vim.org>
parents: 25674
diff changeset
1916 call setline(1, repeat([repeat('b', 60)], 10))
685206b54ecf patch 8.2.3652: can only get text properties one line at a time
Bram Moolenaar <Bram@vim.org>
parents: 25674
diff changeset
1917 call prop_add(1, 4, {'type': 'one', 'id': 5, 'end_col': 6})
685206b54ecf patch 8.2.3652: can only get text properties one line at a time
Bram Moolenaar <Bram@vim.org>
parents: 25674
diff changeset
1918 call prop_add(4, 8, {'type': 'two', 'id': 10, 'end_col': 10})
685206b54ecf patch 8.2.3652: can only get text properties one line at a time
Bram Moolenaar <Bram@vim.org>
parents: 25674
diff changeset
1919 VAR bnr = bufnr()
685206b54ecf patch 8.2.3652: can only get text properties one line at a time
Bram Moolenaar <Bram@vim.org>
parents: 25674
diff changeset
1920 hide edit Xbbb
685206b54ecf patch 8.2.3652: can only get text properties one line at a time
Bram Moolenaar <Bram@vim.org>
parents: 25674
diff changeset
1921 call assert_equal([
685206b54ecf patch 8.2.3652: can only get text properties one line at a time
Bram Moolenaar <Bram@vim.org>
parents: 25674
diff changeset
1922 \ {'lnum': 1, 'id': 5, 'col': 4, 'type_bufnr': 0, 'end': 1,
685206b54ecf patch 8.2.3652: can only get text properties one line at a time
Bram Moolenaar <Bram@vim.org>
parents: 25674
diff changeset
1923 \ 'type': 'one', 'length': 2, 'start': 1},
685206b54ecf patch 8.2.3652: can only get text properties one line at a time
Bram Moolenaar <Bram@vim.org>
parents: 25674
diff changeset
1924 \ {'lnum': 4, 'id': 10, 'col': 8, 'type_bufnr': 0, 'end': 1,
685206b54ecf patch 8.2.3652: can only get text properties one line at a time
Bram Moolenaar <Bram@vim.org>
parents: 25674
diff changeset
1925 \ 'type': 'two', 'length': 2, 'start': 1}],
685206b54ecf patch 8.2.3652: can only get text properties one line at a time
Bram Moolenaar <Bram@vim.org>
parents: 25674
diff changeset
1926 \ prop_list(1, {'bufnr': bnr,
685206b54ecf patch 8.2.3652: can only get text properties one line at a time
Bram Moolenaar <Bram@vim.org>
parents: 25674
diff changeset
1927 \ 'types': ['one', 'two'], 'ids': [5, 10], 'end_lnum': -1}))
685206b54ecf patch 8.2.3652: can only get text properties one line at a time
Bram Moolenaar <Bram@vim.org>
parents: 25674
diff changeset
1928 #" get text properties from an unloaded buffer
685206b54ecf patch 8.2.3652: can only get text properties one line at a time
Bram Moolenaar <Bram@vim.org>
parents: 25674
diff changeset
1929 bunload! Xaaa
685206b54ecf patch 8.2.3652: can only get text properties one line at a time
Bram Moolenaar <Bram@vim.org>
parents: 25674
diff changeset
1930 call assert_equal([], prop_list(1, {'bufnr': bnr, 'end_lnum': -1}))
685206b54ecf patch 8.2.3652: can only get text properties one line at a time
Bram Moolenaar <Bram@vim.org>
parents: 25674
diff changeset
1931
27457
4c16acb2525f patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 26384
diff changeset
1932 call g:DeletePropTypes()
26242
685206b54ecf patch 8.2.3652: can only get text properties one line at a time
Bram Moolenaar <Bram@vim.org>
parents: 25674
diff changeset
1933 :%bw!
685206b54ecf patch 8.2.3652: can only get text properties one line at a time
Bram Moolenaar <Bram@vim.org>
parents: 25674
diff changeset
1934 END
27457
4c16acb2525f patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 26384
diff changeset
1935 call v9.CheckLegacyAndVim9Success(lines)
26242
685206b54ecf patch 8.2.3652: can only get text properties one line at a time
Bram Moolenaar <Bram@vim.org>
parents: 25674
diff changeset
1936 endfunc
23306
90ea5037a7e3 patch 8.2.2198: ml_get error when resizing window and using text property
Bram Moolenaar <Bram@vim.org>
parents: 23072
diff changeset
1937
28526
171f9def0398 patch 8.2.4787: prop_find() does not find the right property
Bram Moolenaar <Bram@vim.org>
parents: 27626
diff changeset
1938 func Test_prop_find_prev_on_same_line()
171f9def0398 patch 8.2.4787: prop_find() does not find the right property
Bram Moolenaar <Bram@vim.org>
parents: 27626
diff changeset
1939 new
171f9def0398 patch 8.2.4787: prop_find() does not find the right property
Bram Moolenaar <Bram@vim.org>
parents: 27626
diff changeset
1940
171f9def0398 patch 8.2.4787: prop_find() does not find the right property
Bram Moolenaar <Bram@vim.org>
parents: 27626
diff changeset
1941 call setline(1, 'the quikc bronw fox jumsp over the layz dog')
171f9def0398 patch 8.2.4787: prop_find() does not find the right property
Bram Moolenaar <Bram@vim.org>
parents: 27626
diff changeset
1942 call prop_type_add('misspell', #{highlight: 'ErrorMsg'})
171f9def0398 patch 8.2.4787: prop_find() does not find the right property
Bram Moolenaar <Bram@vim.org>
parents: 27626
diff changeset
1943 for col in [8, 14, 24, 38]
171f9def0398 patch 8.2.4787: prop_find() does not find the right property
Bram Moolenaar <Bram@vim.org>
parents: 27626
diff changeset
1944 call prop_add(1, col, #{type: 'misspell', length: 2})
171f9def0398 patch 8.2.4787: prop_find() does not find the right property
Bram Moolenaar <Bram@vim.org>
parents: 27626
diff changeset
1945 endfor
171f9def0398 patch 8.2.4787: prop_find() does not find the right property
Bram Moolenaar <Bram@vim.org>
parents: 27626
diff changeset
1946
171f9def0398 patch 8.2.4787: prop_find() does not find the right property
Bram Moolenaar <Bram@vim.org>
parents: 27626
diff changeset
1947 call cursor(1,18)
171f9def0398 patch 8.2.4787: prop_find() does not find the right property
Bram Moolenaar <Bram@vim.org>
parents: 27626
diff changeset
1948 let expected = [
171f9def0398 patch 8.2.4787: prop_find() does not find the right property
Bram Moolenaar <Bram@vim.org>
parents: 27626
diff changeset
1949 \ #{lnum: 1, id: 0, col: 14, end: 1, type: 'misspell', type_bufnr: 0, length: 2, start: 1},
171f9def0398 patch 8.2.4787: prop_find() does not find the right property
Bram Moolenaar <Bram@vim.org>
parents: 27626
diff changeset
1950 \ #{lnum: 1, id: 0, col: 24, end: 1, type: 'misspell', type_bufnr: 0, length: 2, start: 1}
171f9def0398 patch 8.2.4787: prop_find() does not find the right property
Bram Moolenaar <Bram@vim.org>
parents: 27626
diff changeset
1951 \ ]
171f9def0398 patch 8.2.4787: prop_find() does not find the right property
Bram Moolenaar <Bram@vim.org>
parents: 27626
diff changeset
1952
171f9def0398 patch 8.2.4787: prop_find() does not find the right property
Bram Moolenaar <Bram@vim.org>
parents: 27626
diff changeset
1953 let result = prop_find(#{type: 'misspell'}, 'b')
171f9def0398 patch 8.2.4787: prop_find() does not find the right property
Bram Moolenaar <Bram@vim.org>
parents: 27626
diff changeset
1954 call assert_equal(expected[0], result)
171f9def0398 patch 8.2.4787: prop_find() does not find the right property
Bram Moolenaar <Bram@vim.org>
parents: 27626
diff changeset
1955 let result = prop_find(#{type: 'misspell'}, 'f')
171f9def0398 patch 8.2.4787: prop_find() does not find the right property
Bram Moolenaar <Bram@vim.org>
parents: 27626
diff changeset
1956 call assert_equal(expected[1], result)
171f9def0398 patch 8.2.4787: prop_find() does not find the right property
Bram Moolenaar <Bram@vim.org>
parents: 27626
diff changeset
1957
171f9def0398 patch 8.2.4787: prop_find() does not find the right property
Bram Moolenaar <Bram@vim.org>
parents: 27626
diff changeset
1958 call prop_type_delete('misspell')
171f9def0398 patch 8.2.4787: prop_find() does not find the right property
Bram Moolenaar <Bram@vim.org>
parents: 27626
diff changeset
1959 bwipe!
171f9def0398 patch 8.2.4787: prop_find() does not find the right property
Bram Moolenaar <Bram@vim.org>
parents: 27626
diff changeset
1960 endfunc
171f9def0398 patch 8.2.4787: prop_find() does not find the right property
Bram Moolenaar <Bram@vim.org>
parents: 27626
diff changeset
1961
28848
ba81f4ed59e2 patch 8.2.4947: text properties not adjusted when accepting spell suggestion
Bram Moolenaar <Bram@vim.org>
parents: 28841
diff changeset
1962 func Test_prop_spell()
ba81f4ed59e2 patch 8.2.4947: text properties not adjusted when accepting spell suggestion
Bram Moolenaar <Bram@vim.org>
parents: 28841
diff changeset
1963 new
ba81f4ed59e2 patch 8.2.4947: text properties not adjusted when accepting spell suggestion
Bram Moolenaar <Bram@vim.org>
parents: 28841
diff changeset
1964 set spell
ba81f4ed59e2 patch 8.2.4947: text properties not adjusted when accepting spell suggestion
Bram Moolenaar <Bram@vim.org>
parents: 28841
diff changeset
1965 call AddPropTypes()
ba81f4ed59e2 patch 8.2.4947: text properties not adjusted when accepting spell suggestion
Bram Moolenaar <Bram@vim.org>
parents: 28841
diff changeset
1966
ba81f4ed59e2 patch 8.2.4947: text properties not adjusted when accepting spell suggestion
Bram Moolenaar <Bram@vim.org>
parents: 28841
diff changeset
1967 call setline(1, ["helo world", "helo helo helo"])
ba81f4ed59e2 patch 8.2.4947: text properties not adjusted when accepting spell suggestion
Bram Moolenaar <Bram@vim.org>
parents: 28841
diff changeset
1968 call prop_add(1, 1, #{type: 'one', length: 4})
ba81f4ed59e2 patch 8.2.4947: text properties not adjusted when accepting spell suggestion
Bram Moolenaar <Bram@vim.org>
parents: 28841
diff changeset
1969 call prop_add(1, 6, #{type: 'two', length: 5})
ba81f4ed59e2 patch 8.2.4947: text properties not adjusted when accepting spell suggestion
Bram Moolenaar <Bram@vim.org>
parents: 28841
diff changeset
1970 call prop_add(2, 1, #{type: 'three', length: 4})
ba81f4ed59e2 patch 8.2.4947: text properties not adjusted when accepting spell suggestion
Bram Moolenaar <Bram@vim.org>
parents: 28841
diff changeset
1971 call prop_add(2, 6, #{type: 'three', length: 4})
ba81f4ed59e2 patch 8.2.4947: text properties not adjusted when accepting spell suggestion
Bram Moolenaar <Bram@vim.org>
parents: 28841
diff changeset
1972 call prop_add(2, 11, #{type: 'three', length: 4})
ba81f4ed59e2 patch 8.2.4947: text properties not adjusted when accepting spell suggestion
Bram Moolenaar <Bram@vim.org>
parents: 28841
diff changeset
1973
ba81f4ed59e2 patch 8.2.4947: text properties not adjusted when accepting spell suggestion
Bram Moolenaar <Bram@vim.org>
parents: 28841
diff changeset
1974 " The first prop over 'helo' increases its length after the word is corrected
ba81f4ed59e2 patch 8.2.4947: text properties not adjusted when accepting spell suggestion
Bram Moolenaar <Bram@vim.org>
parents: 28841
diff changeset
1975 " to 'Hello', the second one is shifted to the right.
ba81f4ed59e2 patch 8.2.4947: text properties not adjusted when accepting spell suggestion
Bram Moolenaar <Bram@vim.org>
parents: 28841
diff changeset
1976 let expected = [
ba81f4ed59e2 patch 8.2.4947: text properties not adjusted when accepting spell suggestion
Bram Moolenaar <Bram@vim.org>
parents: 28841
diff changeset
1977 \ {'id': 0, 'col': 1, 'type_bufnr': 0, 'end': 1, 'type': 'one',
ba81f4ed59e2 patch 8.2.4947: text properties not adjusted when accepting spell suggestion
Bram Moolenaar <Bram@vim.org>
parents: 28841
diff changeset
1978 \ 'length': 5, 'start': 1},
ba81f4ed59e2 patch 8.2.4947: text properties not adjusted when accepting spell suggestion
Bram Moolenaar <Bram@vim.org>
parents: 28841
diff changeset
1979 \ {'id': 0, 'col': 7, 'type_bufnr': 0, 'end': 1, 'type': 'two',
ba81f4ed59e2 patch 8.2.4947: text properties not adjusted when accepting spell suggestion
Bram Moolenaar <Bram@vim.org>
parents: 28841
diff changeset
1980 \ 'length': 5, 'start': 1}
ba81f4ed59e2 patch 8.2.4947: text properties not adjusted when accepting spell suggestion
Bram Moolenaar <Bram@vim.org>
parents: 28841
diff changeset
1981 \ ]
ba81f4ed59e2 patch 8.2.4947: text properties not adjusted when accepting spell suggestion
Bram Moolenaar <Bram@vim.org>
parents: 28841
diff changeset
1982 call feedkeys("z=1\<CR>", 'xt')
ba81f4ed59e2 patch 8.2.4947: text properties not adjusted when accepting spell suggestion
Bram Moolenaar <Bram@vim.org>
parents: 28841
diff changeset
1983
ba81f4ed59e2 patch 8.2.4947: text properties not adjusted when accepting spell suggestion
Bram Moolenaar <Bram@vim.org>
parents: 28841
diff changeset
1984 call assert_equal('Hello world', getline(1))
ba81f4ed59e2 patch 8.2.4947: text properties not adjusted when accepting spell suggestion
Bram Moolenaar <Bram@vim.org>
parents: 28841
diff changeset
1985 call assert_equal(expected, prop_list(1))
ba81f4ed59e2 patch 8.2.4947: text properties not adjusted when accepting spell suggestion
Bram Moolenaar <Bram@vim.org>
parents: 28841
diff changeset
1986
ba81f4ed59e2 patch 8.2.4947: text properties not adjusted when accepting spell suggestion
Bram Moolenaar <Bram@vim.org>
parents: 28841
diff changeset
1987 " Repeat the replacement done by z=
ba81f4ed59e2 patch 8.2.4947: text properties not adjusted when accepting spell suggestion
Bram Moolenaar <Bram@vim.org>
parents: 28841
diff changeset
1988 spellrepall
ba81f4ed59e2 patch 8.2.4947: text properties not adjusted when accepting spell suggestion
Bram Moolenaar <Bram@vim.org>
parents: 28841
diff changeset
1989
ba81f4ed59e2 patch 8.2.4947: text properties not adjusted when accepting spell suggestion
Bram Moolenaar <Bram@vim.org>
parents: 28841
diff changeset
1990 let expected = [
ba81f4ed59e2 patch 8.2.4947: text properties not adjusted when accepting spell suggestion
Bram Moolenaar <Bram@vim.org>
parents: 28841
diff changeset
1991 \ {'id': 0, 'col': 1, 'type_bufnr': 0, 'end': 1, 'type': 'three',
ba81f4ed59e2 patch 8.2.4947: text properties not adjusted when accepting spell suggestion
Bram Moolenaar <Bram@vim.org>
parents: 28841
diff changeset
1992 \ 'length': 5, 'start': 1},
ba81f4ed59e2 patch 8.2.4947: text properties not adjusted when accepting spell suggestion
Bram Moolenaar <Bram@vim.org>
parents: 28841
diff changeset
1993 \ {'id': 0, 'col': 7, 'type_bufnr': 0, 'end': 1, 'type': 'three',
ba81f4ed59e2 patch 8.2.4947: text properties not adjusted when accepting spell suggestion
Bram Moolenaar <Bram@vim.org>
parents: 28841
diff changeset
1994 \ 'length': 5, 'start': 1},
ba81f4ed59e2 patch 8.2.4947: text properties not adjusted when accepting spell suggestion
Bram Moolenaar <Bram@vim.org>
parents: 28841
diff changeset
1995 \ {'id': 0, 'col': 13, 'type_bufnr': 0, 'end': 1, 'type': 'three',
ba81f4ed59e2 patch 8.2.4947: text properties not adjusted when accepting spell suggestion
Bram Moolenaar <Bram@vim.org>
parents: 28841
diff changeset
1996 \ 'length': 5, 'start': 1}
ba81f4ed59e2 patch 8.2.4947: text properties not adjusted when accepting spell suggestion
Bram Moolenaar <Bram@vim.org>
parents: 28841
diff changeset
1997 \ ]
ba81f4ed59e2 patch 8.2.4947: text properties not adjusted when accepting spell suggestion
Bram Moolenaar <Bram@vim.org>
parents: 28841
diff changeset
1998 call assert_equal('Hello Hello Hello', getline(2))
ba81f4ed59e2 patch 8.2.4947: text properties not adjusted when accepting spell suggestion
Bram Moolenaar <Bram@vim.org>
parents: 28841
diff changeset
1999 call assert_equal(expected, prop_list(2))
ba81f4ed59e2 patch 8.2.4947: text properties not adjusted when accepting spell suggestion
Bram Moolenaar <Bram@vim.org>
parents: 28841
diff changeset
2000
ba81f4ed59e2 patch 8.2.4947: text properties not adjusted when accepting spell suggestion
Bram Moolenaar <Bram@vim.org>
parents: 28841
diff changeset
2001 call DeletePropTypes()
ba81f4ed59e2 patch 8.2.4947: text properties not adjusted when accepting spell suggestion
Bram Moolenaar <Bram@vim.org>
parents: 28841
diff changeset
2002 set spell&
ba81f4ed59e2 patch 8.2.4947: text properties not adjusted when accepting spell suggestion
Bram Moolenaar <Bram@vim.org>
parents: 28841
diff changeset
2003 bwipe!
ba81f4ed59e2 patch 8.2.4947: text properties not adjusted when accepting spell suggestion
Bram Moolenaar <Bram@vim.org>
parents: 28841
diff changeset
2004 endfunc
ba81f4ed59e2 patch 8.2.4947: text properties not adjusted when accepting spell suggestion
Bram Moolenaar <Bram@vim.org>
parents: 28841
diff changeset
2005
28854
647d7f439622 patch 8.2.4950: text properties position wrong after shifting text
Bram Moolenaar <Bram@vim.org>
parents: 28848
diff changeset
2006 func Test_prop_shift_block()
647d7f439622 patch 8.2.4950: text properties position wrong after shifting text
Bram Moolenaar <Bram@vim.org>
parents: 28848
diff changeset
2007 new
647d7f439622 patch 8.2.4950: text properties position wrong after shifting text
Bram Moolenaar <Bram@vim.org>
parents: 28848
diff changeset
2008 call AddPropTypes()
647d7f439622 patch 8.2.4950: text properties position wrong after shifting text
Bram Moolenaar <Bram@vim.org>
parents: 28848
diff changeset
2009
647d7f439622 patch 8.2.4950: text properties position wrong after shifting text
Bram Moolenaar <Bram@vim.org>
parents: 28848
diff changeset
2010 call setline(1, ['some highlighted text']->repeat(2))
647d7f439622 patch 8.2.4950: text properties position wrong after shifting text
Bram Moolenaar <Bram@vim.org>
parents: 28848
diff changeset
2011 call prop_add(1, 10, #{type: 'one', length: 11})
647d7f439622 patch 8.2.4950: text properties position wrong after shifting text
Bram Moolenaar <Bram@vim.org>
parents: 28848
diff changeset
2012 call prop_add(2, 10, #{type: 'two', length: 11})
647d7f439622 patch 8.2.4950: text properties position wrong after shifting text
Bram Moolenaar <Bram@vim.org>
parents: 28848
diff changeset
2013
647d7f439622 patch 8.2.4950: text properties position wrong after shifting text
Bram Moolenaar <Bram@vim.org>
parents: 28848
diff changeset
2014 call cursor(1, 1)
647d7f439622 patch 8.2.4950: text properties position wrong after shifting text
Bram Moolenaar <Bram@vim.org>
parents: 28848
diff changeset
2015 call feedkeys("5l\<c-v>>", 'nxt')
647d7f439622 patch 8.2.4950: text properties position wrong after shifting text
Bram Moolenaar <Bram@vim.org>
parents: 28848
diff changeset
2016 call cursor(2, 1)
647d7f439622 patch 8.2.4950: text properties position wrong after shifting text
Bram Moolenaar <Bram@vim.org>
parents: 28848
diff changeset
2017 call feedkeys("5l\<c-v><", 'nxt')
647d7f439622 patch 8.2.4950: text properties position wrong after shifting text
Bram Moolenaar <Bram@vim.org>
parents: 28848
diff changeset
2018
647d7f439622 patch 8.2.4950: text properties position wrong after shifting text
Bram Moolenaar <Bram@vim.org>
parents: 28848
diff changeset
2019 let expected = [
647d7f439622 patch 8.2.4950: text properties position wrong after shifting text
Bram Moolenaar <Bram@vim.org>
parents: 28848
diff changeset
2020 \ {'lnum': 1, 'id': 0, 'col': 8, 'type_bufnr': 0, 'end': 1, 'type': 'one',
647d7f439622 patch 8.2.4950: text properties position wrong after shifting text
Bram Moolenaar <Bram@vim.org>
parents: 28848
diff changeset
2021 \ 'length': 11, 'start' : 1},
647d7f439622 patch 8.2.4950: text properties position wrong after shifting text
Bram Moolenaar <Bram@vim.org>
parents: 28848
diff changeset
2022 \ {'lnum': 2, 'id': 0, 'col': 6, 'type_bufnr': 0, 'end': 1, 'type': 'two',
647d7f439622 patch 8.2.4950: text properties position wrong after shifting text
Bram Moolenaar <Bram@vim.org>
parents: 28848
diff changeset
2023 \ 'length': 11, 'start' : 1}
647d7f439622 patch 8.2.4950: text properties position wrong after shifting text
Bram Moolenaar <Bram@vim.org>
parents: 28848
diff changeset
2024 \ ]
647d7f439622 patch 8.2.4950: text properties position wrong after shifting text
Bram Moolenaar <Bram@vim.org>
parents: 28848
diff changeset
2025 call assert_equal(expected, prop_list(1, #{end_lnum: 2}))
647d7f439622 patch 8.2.4950: text properties position wrong after shifting text
Bram Moolenaar <Bram@vim.org>
parents: 28848
diff changeset
2026
647d7f439622 patch 8.2.4950: text properties position wrong after shifting text
Bram Moolenaar <Bram@vim.org>
parents: 28848
diff changeset
2027 call DeletePropTypes()
647d7f439622 patch 8.2.4950: text properties position wrong after shifting text
Bram Moolenaar <Bram@vim.org>
parents: 28848
diff changeset
2028 bwipe!
647d7f439622 patch 8.2.4950: text properties position wrong after shifting text
Bram Moolenaar <Bram@vim.org>
parents: 28848
diff changeset
2029 endfunc
28848
ba81f4ed59e2 patch 8.2.4947: text properties not adjusted when accepting spell suggestion
Bram Moolenaar <Bram@vim.org>
parents: 28841
diff changeset
2030
28863
92736a673e3c patch 8.2.4954: inserting line breaks text property spanning two lines
Bram Moolenaar <Bram@vim.org>
parents: 28854
diff changeset
2031 func Test_prop_insert_multiline()
92736a673e3c patch 8.2.4954: inserting line breaks text property spanning two lines
Bram Moolenaar <Bram@vim.org>
parents: 28854
diff changeset
2032 new
92736a673e3c patch 8.2.4954: inserting line breaks text property spanning two lines
Bram Moolenaar <Bram@vim.org>
parents: 28854
diff changeset
2033 call AddPropTypes()
92736a673e3c patch 8.2.4954: inserting line breaks text property spanning two lines
Bram Moolenaar <Bram@vim.org>
parents: 28854
diff changeset
2034
92736a673e3c patch 8.2.4954: inserting line breaks text property spanning two lines
Bram Moolenaar <Bram@vim.org>
parents: 28854
diff changeset
2035 call setline(1, ['foobar', 'barbaz'])
92736a673e3c patch 8.2.4954: inserting line breaks text property spanning two lines
Bram Moolenaar <Bram@vim.org>
parents: 28854
diff changeset
2036 call prop_add(1, 4, #{end_lnum: 2, end_col: 4, type: 'one'})
92736a673e3c patch 8.2.4954: inserting line breaks text property spanning two lines
Bram Moolenaar <Bram@vim.org>
parents: 28854
diff changeset
2037
92736a673e3c patch 8.2.4954: inserting line breaks text property spanning two lines
Bram Moolenaar <Bram@vim.org>
parents: 28854
diff changeset
2038 call feedkeys("1Goquxqux\<Esc>", 'nxt')
92736a673e3c patch 8.2.4954: inserting line breaks text property spanning two lines
Bram Moolenaar <Bram@vim.org>
parents: 28854
diff changeset
2039 call feedkeys("2GOquxqux\<Esc>", 'nxt')
92736a673e3c patch 8.2.4954: inserting line breaks text property spanning two lines
Bram Moolenaar <Bram@vim.org>
parents: 28854
diff changeset
2040
92736a673e3c patch 8.2.4954: inserting line breaks text property spanning two lines
Bram Moolenaar <Bram@vim.org>
parents: 28854
diff changeset
2041 let lines =<< trim END
92736a673e3c patch 8.2.4954: inserting line breaks text property spanning two lines
Bram Moolenaar <Bram@vim.org>
parents: 28854
diff changeset
2042 foobar
92736a673e3c patch 8.2.4954: inserting line breaks text property spanning two lines
Bram Moolenaar <Bram@vim.org>
parents: 28854
diff changeset
2043 quxqux
92736a673e3c patch 8.2.4954: inserting line breaks text property spanning two lines
Bram Moolenaar <Bram@vim.org>
parents: 28854
diff changeset
2044 quxqux
92736a673e3c patch 8.2.4954: inserting line breaks text property spanning two lines
Bram Moolenaar <Bram@vim.org>
parents: 28854
diff changeset
2045 barbaz
92736a673e3c patch 8.2.4954: inserting line breaks text property spanning two lines
Bram Moolenaar <Bram@vim.org>
parents: 28854
diff changeset
2046 END
92736a673e3c patch 8.2.4954: inserting line breaks text property spanning two lines
Bram Moolenaar <Bram@vim.org>
parents: 28854
diff changeset
2047 call assert_equal(lines, getline(1, '$'))
92736a673e3c patch 8.2.4954: inserting line breaks text property spanning two lines
Bram Moolenaar <Bram@vim.org>
parents: 28854
diff changeset
2048 let expected = [
92736a673e3c patch 8.2.4954: inserting line breaks text property spanning two lines
Bram Moolenaar <Bram@vim.org>
parents: 28854
diff changeset
2049 \ {'lnum': 1, 'id': 0, 'col': 4, 'type_bufnr': 0, 'end': 0, 'type': 'one',
92736a673e3c patch 8.2.4954: inserting line breaks text property spanning two lines
Bram Moolenaar <Bram@vim.org>
parents: 28854
diff changeset
2050 \ 'length': 4 ,'start': 1},
92736a673e3c patch 8.2.4954: inserting line breaks text property spanning two lines
Bram Moolenaar <Bram@vim.org>
parents: 28854
diff changeset
2051 \ {'lnum': 2, 'id': 0, 'col': 1, 'type_bufnr': 0, 'end': 0, 'type': 'one',
92736a673e3c patch 8.2.4954: inserting line breaks text property spanning two lines
Bram Moolenaar <Bram@vim.org>
parents: 28854
diff changeset
2052 \ 'length': 7, 'start': 0},
92736a673e3c patch 8.2.4954: inserting line breaks text property spanning two lines
Bram Moolenaar <Bram@vim.org>
parents: 28854
diff changeset
2053 \ {'lnum': 3, 'id': 0, 'col': 1, 'type_bufnr': 0, 'end': 0, 'type': 'one',
92736a673e3c patch 8.2.4954: inserting line breaks text property spanning two lines
Bram Moolenaar <Bram@vim.org>
parents: 28854
diff changeset
2054 \ 'length': 7, 'start': 0},
92736a673e3c patch 8.2.4954: inserting line breaks text property spanning two lines
Bram Moolenaar <Bram@vim.org>
parents: 28854
diff changeset
2055 \ {'lnum': 4, 'id': 0, 'col': 1, 'type_bufnr': 0, 'end': 1, 'type': 'one',
92736a673e3c patch 8.2.4954: inserting line breaks text property spanning two lines
Bram Moolenaar <Bram@vim.org>
parents: 28854
diff changeset
2056 \ 'length': 3, 'start': 0}
92736a673e3c patch 8.2.4954: inserting line breaks text property spanning two lines
Bram Moolenaar <Bram@vim.org>
parents: 28854
diff changeset
2057 \ ]
92736a673e3c patch 8.2.4954: inserting line breaks text property spanning two lines
Bram Moolenaar <Bram@vim.org>
parents: 28854
diff changeset
2058 call assert_equal(expected, prop_list(1, #{end_lnum: 10}))
92736a673e3c patch 8.2.4954: inserting line breaks text property spanning two lines
Bram Moolenaar <Bram@vim.org>
parents: 28854
diff changeset
2059
92736a673e3c patch 8.2.4954: inserting line breaks text property spanning two lines
Bram Moolenaar <Bram@vim.org>
parents: 28854
diff changeset
2060 call DeletePropTypes()
92736a673e3c patch 8.2.4954: inserting line breaks text property spanning two lines
Bram Moolenaar <Bram@vim.org>
parents: 28854
diff changeset
2061 bwipe!
92736a673e3c patch 8.2.4954: inserting line breaks text property spanning two lines
Bram Moolenaar <Bram@vim.org>
parents: 28854
diff changeset
2062 endfunc
92736a673e3c patch 8.2.4954: inserting line breaks text property spanning two lines
Bram Moolenaar <Bram@vim.org>
parents: 28854
diff changeset
2063
28869
6a4edacbd178 patch 8.2.4957: text properties in a wrong position after a block change
Bram Moolenaar <Bram@vim.org>
parents: 28865
diff changeset
2064 func Test_prop_blockwise_change()
6a4edacbd178 patch 8.2.4957: text properties in a wrong position after a block change
Bram Moolenaar <Bram@vim.org>
parents: 28865
diff changeset
2065 new
6a4edacbd178 patch 8.2.4957: text properties in a wrong position after a block change
Bram Moolenaar <Bram@vim.org>
parents: 28865
diff changeset
2066 call AddPropTypes()
6a4edacbd178 patch 8.2.4957: text properties in a wrong position after a block change
Bram Moolenaar <Bram@vim.org>
parents: 28865
diff changeset
2067
6a4edacbd178 patch 8.2.4957: text properties in a wrong position after a block change
Bram Moolenaar <Bram@vim.org>
parents: 28865
diff changeset
2068 call setline(1, ['foooooo', 'bar', 'baaaaz'])
6a4edacbd178 patch 8.2.4957: text properties in a wrong position after a block change
Bram Moolenaar <Bram@vim.org>
parents: 28865
diff changeset
2069 call prop_add(1, 1, #{end_col: 3, type: 'one'})
6a4edacbd178 patch 8.2.4957: text properties in a wrong position after a block change
Bram Moolenaar <Bram@vim.org>
parents: 28865
diff changeset
2070 call prop_add(2, 1, #{end_col: 3, type: 'two'})
6a4edacbd178 patch 8.2.4957: text properties in a wrong position after a block change
Bram Moolenaar <Bram@vim.org>
parents: 28865
diff changeset
2071 call prop_add(3, 1, #{end_col: 3, type: 'three'})
6a4edacbd178 patch 8.2.4957: text properties in a wrong position after a block change
Bram Moolenaar <Bram@vim.org>
parents: 28865
diff changeset
2072
6a4edacbd178 patch 8.2.4957: text properties in a wrong position after a block change
Bram Moolenaar <Bram@vim.org>
parents: 28865
diff changeset
2073 " Replace the first two columns with '123', since 'start_incl' is false the
6a4edacbd178 patch 8.2.4957: text properties in a wrong position after a block change
Bram Moolenaar <Bram@vim.org>
parents: 28865
diff changeset
2074 " prop is not extended.
6a4edacbd178 patch 8.2.4957: text properties in a wrong position after a block change
Bram Moolenaar <Bram@vim.org>
parents: 28865
diff changeset
2075 call feedkeys("gg\<c-v>2jc123\<Esc>", 'nxt')
6a4edacbd178 patch 8.2.4957: text properties in a wrong position after a block change
Bram Moolenaar <Bram@vim.org>
parents: 28865
diff changeset
2076
6a4edacbd178 patch 8.2.4957: text properties in a wrong position after a block change
Bram Moolenaar <Bram@vim.org>
parents: 28865
diff changeset
2077 let lines =<< trim END
6a4edacbd178 patch 8.2.4957: text properties in a wrong position after a block change
Bram Moolenaar <Bram@vim.org>
parents: 28865
diff changeset
2078 123oooooo
6a4edacbd178 patch 8.2.4957: text properties in a wrong position after a block change
Bram Moolenaar <Bram@vim.org>
parents: 28865
diff changeset
2079 123ar
6a4edacbd178 patch 8.2.4957: text properties in a wrong position after a block change
Bram Moolenaar <Bram@vim.org>
parents: 28865
diff changeset
2080 123aaaaz
6a4edacbd178 patch 8.2.4957: text properties in a wrong position after a block change
Bram Moolenaar <Bram@vim.org>
parents: 28865
diff changeset
2081 END
6a4edacbd178 patch 8.2.4957: text properties in a wrong position after a block change
Bram Moolenaar <Bram@vim.org>
parents: 28865
diff changeset
2082 call assert_equal(lines, getline(1, '$'))
6a4edacbd178 patch 8.2.4957: text properties in a wrong position after a block change
Bram Moolenaar <Bram@vim.org>
parents: 28865
diff changeset
2083 let expected = [
6a4edacbd178 patch 8.2.4957: text properties in a wrong position after a block change
Bram Moolenaar <Bram@vim.org>
parents: 28865
diff changeset
2084 \ {'lnum': 1, 'id': 0, 'col': 4, 'type_bufnr': 0, 'end': 1, 'type': 'one',
6a4edacbd178 patch 8.2.4957: text properties in a wrong position after a block change
Bram Moolenaar <Bram@vim.org>
parents: 28865
diff changeset
2085 \ 'length': 1, 'start': 1},
6a4edacbd178 patch 8.2.4957: text properties in a wrong position after a block change
Bram Moolenaar <Bram@vim.org>
parents: 28865
diff changeset
2086 \ {'lnum': 2, 'id': 0, 'col': 4, 'type_bufnr': 0, 'end': 1, 'type': 'two',
6a4edacbd178 patch 8.2.4957: text properties in a wrong position after a block change
Bram Moolenaar <Bram@vim.org>
parents: 28865
diff changeset
2087 \ 'length': 1, 'start': 1},
6a4edacbd178 patch 8.2.4957: text properties in a wrong position after a block change
Bram Moolenaar <Bram@vim.org>
parents: 28865
diff changeset
2088 \ {'lnum': 3, 'id': 0, 'col': 4, 'type_bufnr': 0, 'end': 1 ,
6a4edacbd178 patch 8.2.4957: text properties in a wrong position after a block change
Bram Moolenaar <Bram@vim.org>
parents: 28865
diff changeset
2089 \ 'type': 'three', 'length': 1, 'start': 1}
6a4edacbd178 patch 8.2.4957: text properties in a wrong position after a block change
Bram Moolenaar <Bram@vim.org>
parents: 28865
diff changeset
2090 \ ]
6a4edacbd178 patch 8.2.4957: text properties in a wrong position after a block change
Bram Moolenaar <Bram@vim.org>
parents: 28865
diff changeset
2091 call assert_equal(expected, prop_list(1, #{end_lnum: 10}))
6a4edacbd178 patch 8.2.4957: text properties in a wrong position after a block change
Bram Moolenaar <Bram@vim.org>
parents: 28865
diff changeset
2092
6a4edacbd178 patch 8.2.4957: text properties in a wrong position after a block change
Bram Moolenaar <Bram@vim.org>
parents: 28865
diff changeset
2093 call DeletePropTypes()
6a4edacbd178 patch 8.2.4957: text properties in a wrong position after a block change
Bram Moolenaar <Bram@vim.org>
parents: 28865
diff changeset
2094 bwipe!
6a4edacbd178 patch 8.2.4957: text properties in a wrong position after a block change
Bram Moolenaar <Bram@vim.org>
parents: 28865
diff changeset
2095 endfunc
6a4edacbd178 patch 8.2.4957: text properties in a wrong position after a block change
Bram Moolenaar <Bram@vim.org>
parents: 28865
diff changeset
2096
28984
b3828315a0d9 patch 8.2.5014: byte offsets are wrong when using text properties
Bram Moolenaar <Bram@vim.org>
parents: 28931
diff changeset
2097 func Do_test_props_do_not_affect_byte_offsets(ff, increment)
b3828315a0d9 patch 8.2.5014: byte offsets are wrong when using text properties
Bram Moolenaar <Bram@vim.org>
parents: 28931
diff changeset
2098 new
b3828315a0d9 patch 8.2.5014: byte offsets are wrong when using text properties
Bram Moolenaar <Bram@vim.org>
parents: 28931
diff changeset
2099 let lcount = 410
b3828315a0d9 patch 8.2.5014: byte offsets are wrong when using text properties
Bram Moolenaar <Bram@vim.org>
parents: 28931
diff changeset
2100
b3828315a0d9 patch 8.2.5014: byte offsets are wrong when using text properties
Bram Moolenaar <Bram@vim.org>
parents: 28931
diff changeset
2101 " File format affects byte-offset calculations, so make sure it is known.
b3828315a0d9 patch 8.2.5014: byte offsets are wrong when using text properties
Bram Moolenaar <Bram@vim.org>
parents: 28931
diff changeset
2102 exec 'setlocal fileformat=' . a:ff
b3828315a0d9 patch 8.2.5014: byte offsets are wrong when using text properties
Bram Moolenaar <Bram@vim.org>
parents: 28931
diff changeset
2103
b3828315a0d9 patch 8.2.5014: byte offsets are wrong when using text properties
Bram Moolenaar <Bram@vim.org>
parents: 28931
diff changeset
2104 " Fill the buffer with varying length lines. We need a suitably large number
b3828315a0d9 patch 8.2.5014: byte offsets are wrong when using text properties
Bram Moolenaar <Bram@vim.org>
parents: 28931
diff changeset
2105 " to force Vim code through paths wehere previous error have occurred. This
b3828315a0d9 patch 8.2.5014: byte offsets are wrong when using text properties
Bram Moolenaar <Bram@vim.org>
parents: 28931
diff changeset
2106 " is more 'art' than 'science'.
b3828315a0d9 patch 8.2.5014: byte offsets are wrong when using text properties
Bram Moolenaar <Bram@vim.org>
parents: 28931
diff changeset
2107 let text = 'a'
b3828315a0d9 patch 8.2.5014: byte offsets are wrong when using text properties
Bram Moolenaar <Bram@vim.org>
parents: 28931
diff changeset
2108 call setline(1, text)
b3828315a0d9 patch 8.2.5014: byte offsets are wrong when using text properties
Bram Moolenaar <Bram@vim.org>
parents: 28931
diff changeset
2109 let offsets = [1]
b3828315a0d9 patch 8.2.5014: byte offsets are wrong when using text properties
Bram Moolenaar <Bram@vim.org>
parents: 28931
diff changeset
2110 for idx in range(lcount)
b3828315a0d9 patch 8.2.5014: byte offsets are wrong when using text properties
Bram Moolenaar <Bram@vim.org>
parents: 28931
diff changeset
2111 call add(offsets, offsets[idx] + len(text) + a:increment)
b3828315a0d9 patch 8.2.5014: byte offsets are wrong when using text properties
Bram Moolenaar <Bram@vim.org>
parents: 28931
diff changeset
2112 if (idx % 6) == 0
b3828315a0d9 patch 8.2.5014: byte offsets are wrong when using text properties
Bram Moolenaar <Bram@vim.org>
parents: 28931
diff changeset
2113 let text = text . 'a'
b3828315a0d9 patch 8.2.5014: byte offsets are wrong when using text properties
Bram Moolenaar <Bram@vim.org>
parents: 28931
diff changeset
2114 endif
b3828315a0d9 patch 8.2.5014: byte offsets are wrong when using text properties
Bram Moolenaar <Bram@vim.org>
parents: 28931
diff changeset
2115 call append(line('$'), text)
b3828315a0d9 patch 8.2.5014: byte offsets are wrong when using text properties
Bram Moolenaar <Bram@vim.org>
parents: 28931
diff changeset
2116 endfor
b3828315a0d9 patch 8.2.5014: byte offsets are wrong when using text properties
Bram Moolenaar <Bram@vim.org>
parents: 28931
diff changeset
2117
b3828315a0d9 patch 8.2.5014: byte offsets are wrong when using text properties
Bram Moolenaar <Bram@vim.org>
parents: 28931
diff changeset
2118 " Set a property that spans a few lines to cause Vim's internal buffer code
b3828315a0d9 patch 8.2.5014: byte offsets are wrong when using text properties
Bram Moolenaar <Bram@vim.org>
parents: 28931
diff changeset
2119 " to perform a reasonable amount of rearrangement.
b3828315a0d9 patch 8.2.5014: byte offsets are wrong when using text properties
Bram Moolenaar <Bram@vim.org>
parents: 28931
diff changeset
2120 call prop_type_add('one', {'highlight': 'ErrorMsg'})
b3828315a0d9 patch 8.2.5014: byte offsets are wrong when using text properties
Bram Moolenaar <Bram@vim.org>
parents: 28931
diff changeset
2121 call prop_add(1, 1, {'type': 'one', 'end_lnum': 6, 'end_col': 2})
b3828315a0d9 patch 8.2.5014: byte offsets are wrong when using text properties
Bram Moolenaar <Bram@vim.org>
parents: 28931
diff changeset
2122
b3828315a0d9 patch 8.2.5014: byte offsets are wrong when using text properties
Bram Moolenaar <Bram@vim.org>
parents: 28931
diff changeset
2123 for idx in range(lcount)
b3828315a0d9 patch 8.2.5014: byte offsets are wrong when using text properties
Bram Moolenaar <Bram@vim.org>
parents: 28931
diff changeset
2124 let boff = line2byte(idx + 1)
b3828315a0d9 patch 8.2.5014: byte offsets are wrong when using text properties
Bram Moolenaar <Bram@vim.org>
parents: 28931
diff changeset
2125 call assert_equal(offsets[idx], boff, 'Bad byte offset at line ' . (idx + 1))
b3828315a0d9 patch 8.2.5014: byte offsets are wrong when using text properties
Bram Moolenaar <Bram@vim.org>
parents: 28931
diff changeset
2126 endfor
b3828315a0d9 patch 8.2.5014: byte offsets are wrong when using text properties
Bram Moolenaar <Bram@vim.org>
parents: 28931
diff changeset
2127
b3828315a0d9 patch 8.2.5014: byte offsets are wrong when using text properties
Bram Moolenaar <Bram@vim.org>
parents: 28931
diff changeset
2128 call prop_type_delete('one')
b3828315a0d9 patch 8.2.5014: byte offsets are wrong when using text properties
Bram Moolenaar <Bram@vim.org>
parents: 28931
diff changeset
2129 bwipe!
b3828315a0d9 patch 8.2.5014: byte offsets are wrong when using text properties
Bram Moolenaar <Bram@vim.org>
parents: 28931
diff changeset
2130 endfunc
b3828315a0d9 patch 8.2.5014: byte offsets are wrong when using text properties
Bram Moolenaar <Bram@vim.org>
parents: 28931
diff changeset
2131
b3828315a0d9 patch 8.2.5014: byte offsets are wrong when using text properties
Bram Moolenaar <Bram@vim.org>
parents: 28931
diff changeset
2132 func Test_props_do_not_affect_byte_offsets()
b3828315a0d9 patch 8.2.5014: byte offsets are wrong when using text properties
Bram Moolenaar <Bram@vim.org>
parents: 28931
diff changeset
2133 call Do_test_props_do_not_affect_byte_offsets('unix', 1)
b3828315a0d9 patch 8.2.5014: byte offsets are wrong when using text properties
Bram Moolenaar <Bram@vim.org>
parents: 28931
diff changeset
2134 endfunc
b3828315a0d9 patch 8.2.5014: byte offsets are wrong when using text properties
Bram Moolenaar <Bram@vim.org>
parents: 28931
diff changeset
2135
b3828315a0d9 patch 8.2.5014: byte offsets are wrong when using text properties
Bram Moolenaar <Bram@vim.org>
parents: 28931
diff changeset
2136 func Test_props_do_not_affect_byte_offsets_dos()
b3828315a0d9 patch 8.2.5014: byte offsets are wrong when using text properties
Bram Moolenaar <Bram@vim.org>
parents: 28931
diff changeset
2137 call Do_test_props_do_not_affect_byte_offsets('dos', 2)
b3828315a0d9 patch 8.2.5014: byte offsets are wrong when using text properties
Bram Moolenaar <Bram@vim.org>
parents: 28931
diff changeset
2138 endfunc
b3828315a0d9 patch 8.2.5014: byte offsets are wrong when using text properties
Bram Moolenaar <Bram@vim.org>
parents: 28931
diff changeset
2139
b3828315a0d9 patch 8.2.5014: byte offsets are wrong when using text properties
Bram Moolenaar <Bram@vim.org>
parents: 28931
diff changeset
2140 func Test_props_do_not_affect_byte_offsets_editline()
b3828315a0d9 patch 8.2.5014: byte offsets are wrong when using text properties
Bram Moolenaar <Bram@vim.org>
parents: 28931
diff changeset
2141 new
b3828315a0d9 patch 8.2.5014: byte offsets are wrong when using text properties
Bram Moolenaar <Bram@vim.org>
parents: 28931
diff changeset
2142 let lcount = 410
b3828315a0d9 patch 8.2.5014: byte offsets are wrong when using text properties
Bram Moolenaar <Bram@vim.org>
parents: 28931
diff changeset
2143
b3828315a0d9 patch 8.2.5014: byte offsets are wrong when using text properties
Bram Moolenaar <Bram@vim.org>
parents: 28931
diff changeset
2144 " File format affects byte-offset calculations, so make sure it is known.
b3828315a0d9 patch 8.2.5014: byte offsets are wrong when using text properties
Bram Moolenaar <Bram@vim.org>
parents: 28931
diff changeset
2145 setlocal fileformat=unix
b3828315a0d9 patch 8.2.5014: byte offsets are wrong when using text properties
Bram Moolenaar <Bram@vim.org>
parents: 28931
diff changeset
2146
b3828315a0d9 patch 8.2.5014: byte offsets are wrong when using text properties
Bram Moolenaar <Bram@vim.org>
parents: 28931
diff changeset
2147 " Fill the buffer with varying length lines. We need a suitably large number
b3828315a0d9 patch 8.2.5014: byte offsets are wrong when using text properties
Bram Moolenaar <Bram@vim.org>
parents: 28931
diff changeset
2148 " to force Vim code through paths wehere previous error have occurred. This
b3828315a0d9 patch 8.2.5014: byte offsets are wrong when using text properties
Bram Moolenaar <Bram@vim.org>
parents: 28931
diff changeset
2149 " is more 'art' than 'science'.
b3828315a0d9 patch 8.2.5014: byte offsets are wrong when using text properties
Bram Moolenaar <Bram@vim.org>
parents: 28931
diff changeset
2150 let text = 'aa'
b3828315a0d9 patch 8.2.5014: byte offsets are wrong when using text properties
Bram Moolenaar <Bram@vim.org>
parents: 28931
diff changeset
2151 call setline(1, text)
b3828315a0d9 patch 8.2.5014: byte offsets are wrong when using text properties
Bram Moolenaar <Bram@vim.org>
parents: 28931
diff changeset
2152 let offsets = [1]
b3828315a0d9 patch 8.2.5014: byte offsets are wrong when using text properties
Bram Moolenaar <Bram@vim.org>
parents: 28931
diff changeset
2153 for idx in range(lcount)
b3828315a0d9 patch 8.2.5014: byte offsets are wrong when using text properties
Bram Moolenaar <Bram@vim.org>
parents: 28931
diff changeset
2154 call add(offsets, offsets[idx] + len(text) + 1)
b3828315a0d9 patch 8.2.5014: byte offsets are wrong when using text properties
Bram Moolenaar <Bram@vim.org>
parents: 28931
diff changeset
2155 if (idx % 6) == 0
b3828315a0d9 patch 8.2.5014: byte offsets are wrong when using text properties
Bram Moolenaar <Bram@vim.org>
parents: 28931
diff changeset
2156 let text = text . 'a'
b3828315a0d9 patch 8.2.5014: byte offsets are wrong when using text properties
Bram Moolenaar <Bram@vim.org>
parents: 28931
diff changeset
2157 endif
b3828315a0d9 patch 8.2.5014: byte offsets are wrong when using text properties
Bram Moolenaar <Bram@vim.org>
parents: 28931
diff changeset
2158 call append(line('$'), text)
b3828315a0d9 patch 8.2.5014: byte offsets are wrong when using text properties
Bram Moolenaar <Bram@vim.org>
parents: 28931
diff changeset
2159 endfor
b3828315a0d9 patch 8.2.5014: byte offsets are wrong when using text properties
Bram Moolenaar <Bram@vim.org>
parents: 28931
diff changeset
2160
b3828315a0d9 patch 8.2.5014: byte offsets are wrong when using text properties
Bram Moolenaar <Bram@vim.org>
parents: 28931
diff changeset
2161 " Set a property that just covers the first line. When this test was
b3828315a0d9 patch 8.2.5014: byte offsets are wrong when using text properties
Bram Moolenaar <Bram@vim.org>
parents: 28931
diff changeset
2162 " developed, this did not trigger a byte-offset error.
b3828315a0d9 patch 8.2.5014: byte offsets are wrong when using text properties
Bram Moolenaar <Bram@vim.org>
parents: 28931
diff changeset
2163 call prop_type_add('one', {'highlight': 'ErrorMsg'})
b3828315a0d9 patch 8.2.5014: byte offsets are wrong when using text properties
Bram Moolenaar <Bram@vim.org>
parents: 28931
diff changeset
2164 call prop_add(1, 1, {'type': 'one', 'end_lnum': 1, 'end_col': 3})
b3828315a0d9 patch 8.2.5014: byte offsets are wrong when using text properties
Bram Moolenaar <Bram@vim.org>
parents: 28931
diff changeset
2165
b3828315a0d9 patch 8.2.5014: byte offsets are wrong when using text properties
Bram Moolenaar <Bram@vim.org>
parents: 28931
diff changeset
2166 for idx in range(lcount)
b3828315a0d9 patch 8.2.5014: byte offsets are wrong when using text properties
Bram Moolenaar <Bram@vim.org>
parents: 28931
diff changeset
2167 let boff = line2byte(idx + 1)
b3828315a0d9 patch 8.2.5014: byte offsets are wrong when using text properties
Bram Moolenaar <Bram@vim.org>
parents: 28931
diff changeset
2168 call assert_equal(offsets[idx], boff,
b3828315a0d9 patch 8.2.5014: byte offsets are wrong when using text properties
Bram Moolenaar <Bram@vim.org>
parents: 28931
diff changeset
2169 \ 'Confounding bad byte offset at line ' . (idx + 1))
b3828315a0d9 patch 8.2.5014: byte offsets are wrong when using text properties
Bram Moolenaar <Bram@vim.org>
parents: 28931
diff changeset
2170 endfor
b3828315a0d9 patch 8.2.5014: byte offsets are wrong when using text properties
Bram Moolenaar <Bram@vim.org>
parents: 28931
diff changeset
2171
b3828315a0d9 patch 8.2.5014: byte offsets are wrong when using text properties
Bram Moolenaar <Bram@vim.org>
parents: 28931
diff changeset
2172 " Insert text in the middle of the first line, keeping the property
b3828315a0d9 patch 8.2.5014: byte offsets are wrong when using text properties
Bram Moolenaar <Bram@vim.org>
parents: 28931
diff changeset
2173 " unchanged.
b3828315a0d9 patch 8.2.5014: byte offsets are wrong when using text properties
Bram Moolenaar <Bram@vim.org>
parents: 28931
diff changeset
2174 :1
b3828315a0d9 patch 8.2.5014: byte offsets are wrong when using text properties
Bram Moolenaar <Bram@vim.org>
parents: 28931
diff changeset
2175 normal aHello
b3828315a0d9 patch 8.2.5014: byte offsets are wrong when using text properties
Bram Moolenaar <Bram@vim.org>
parents: 28931
diff changeset
2176 for idx in range(1, lcount)
b3828315a0d9 patch 8.2.5014: byte offsets are wrong when using text properties
Bram Moolenaar <Bram@vim.org>
parents: 28931
diff changeset
2177 let offsets[idx] = offsets[idx] + 5
b3828315a0d9 patch 8.2.5014: byte offsets are wrong when using text properties
Bram Moolenaar <Bram@vim.org>
parents: 28931
diff changeset
2178 endfor
b3828315a0d9 patch 8.2.5014: byte offsets are wrong when using text properties
Bram Moolenaar <Bram@vim.org>
parents: 28931
diff changeset
2179
b3828315a0d9 patch 8.2.5014: byte offsets are wrong when using text properties
Bram Moolenaar <Bram@vim.org>
parents: 28931
diff changeset
2180 for idx in range(lcount)
b3828315a0d9 patch 8.2.5014: byte offsets are wrong when using text properties
Bram Moolenaar <Bram@vim.org>
parents: 28931
diff changeset
2181 let boff = line2byte(idx + 1)
b3828315a0d9 patch 8.2.5014: byte offsets are wrong when using text properties
Bram Moolenaar <Bram@vim.org>
parents: 28931
diff changeset
2182 call assert_equal(offsets[idx], boff,
b3828315a0d9 patch 8.2.5014: byte offsets are wrong when using text properties
Bram Moolenaar <Bram@vim.org>
parents: 28931
diff changeset
2183 \ 'Bad byte offset at line ' . (idx + 1))
b3828315a0d9 patch 8.2.5014: byte offsets are wrong when using text properties
Bram Moolenaar <Bram@vim.org>
parents: 28931
diff changeset
2184 endfor
b3828315a0d9 patch 8.2.5014: byte offsets are wrong when using text properties
Bram Moolenaar <Bram@vim.org>
parents: 28931
diff changeset
2185
b3828315a0d9 patch 8.2.5014: byte offsets are wrong when using text properties
Bram Moolenaar <Bram@vim.org>
parents: 28931
diff changeset
2186 call prop_type_delete('one')
b3828315a0d9 patch 8.2.5014: byte offsets are wrong when using text properties
Bram Moolenaar <Bram@vim.org>
parents: 28931
diff changeset
2187 bwipe!
b3828315a0d9 patch 8.2.5014: byte offsets are wrong when using text properties
Bram Moolenaar <Bram@vim.org>
parents: 28931
diff changeset
2188 endfunc
b3828315a0d9 patch 8.2.5014: byte offsets are wrong when using text properties
Bram Moolenaar <Bram@vim.org>
parents: 28931
diff changeset
2189
29451
057c26b5c33a patch 9.0.0067: cannot show virtual text
Bram Moolenaar <Bram@vim.org>
parents: 28984
diff changeset
2190 func Test_prop_inserts_text()
057c26b5c33a patch 9.0.0067: cannot show virtual text
Bram Moolenaar <Bram@vim.org>
parents: 28984
diff changeset
2191 CheckRunVimInTerminal
057c26b5c33a patch 9.0.0067: cannot show virtual text
Bram Moolenaar <Bram@vim.org>
parents: 28984
diff changeset
2192
057c26b5c33a patch 9.0.0067: cannot show virtual text
Bram Moolenaar <Bram@vim.org>
parents: 28984
diff changeset
2193 " Just a basic check for now
057c26b5c33a patch 9.0.0067: cannot show virtual text
Bram Moolenaar <Bram@vim.org>
parents: 28984
diff changeset
2194 let lines =<< trim END
057c26b5c33a patch 9.0.0067: cannot show virtual text
Bram Moolenaar <Bram@vim.org>
parents: 28984
diff changeset
2195 call setline(1, 'insert some text here and other text there and some more text after wrapping')
057c26b5c33a patch 9.0.0067: cannot show virtual text
Bram Moolenaar <Bram@vim.org>
parents: 28984
diff changeset
2196 call prop_type_add('someprop', #{highlight: 'ErrorMsg'})
057c26b5c33a patch 9.0.0067: cannot show virtual text
Bram Moolenaar <Bram@vim.org>
parents: 28984
diff changeset
2197 call prop_type_add('otherprop', #{highlight: 'Search'})
057c26b5c33a patch 9.0.0067: cannot show virtual text
Bram Moolenaar <Bram@vim.org>
parents: 28984
diff changeset
2198 call prop_type_add('moreprop', #{highlight: 'DiffAdd'})
057c26b5c33a patch 9.0.0067: cannot show virtual text
Bram Moolenaar <Bram@vim.org>
parents: 28984
diff changeset
2199 call prop_add(1, 18, #{type: 'someprop', text: 'SOME '})
29581
4a79bca8a76e patch 9.0.0131: virtual text with Tab is not displayed correctly
Bram Moolenaar <Bram@vim.org>
parents: 29579
diff changeset
2200 call prop_add(1, 38, #{type: 'otherprop', text: "OTHER\t"})
29451
057c26b5c33a patch 9.0.0067: cannot show virtual text
Bram Moolenaar <Bram@vim.org>
parents: 28984
diff changeset
2201 call prop_add(1, 69, #{type: 'moreprop', text: 'MORE '})
057c26b5c33a patch 9.0.0067: cannot show virtual text
Bram Moolenaar <Bram@vim.org>
parents: 28984
diff changeset
2202 normal $
29583
32aee589fc9a patch 9.0.0132: multi-byte characters in virtual text not handled correctly
Bram Moolenaar <Bram@vim.org>
parents: 29581
diff changeset
2203
32aee589fc9a patch 9.0.0132: multi-byte characters in virtual text not handled correctly
Bram Moolenaar <Bram@vim.org>
parents: 29581
diff changeset
2204 call setline(2, 'prepost')
32aee589fc9a patch 9.0.0132: multi-byte characters in virtual text not handled correctly
Bram Moolenaar <Bram@vim.org>
parents: 29581
diff changeset
2205 call prop_type_add('multibyte', #{highlight: 'Visual'})
32aee589fc9a patch 9.0.0132: multi-byte characters in virtual text not handled correctly
Bram Moolenaar <Bram@vim.org>
parents: 29581
diff changeset
2206 call prop_add(2, 4, #{type: 'multibyte', text: 'söme和平téxt'})
29451
057c26b5c33a patch 9.0.0067: cannot show virtual text
Bram Moolenaar <Bram@vim.org>
parents: 28984
diff changeset
2207 END
057c26b5c33a patch 9.0.0067: cannot show virtual text
Bram Moolenaar <Bram@vim.org>
parents: 28984
diff changeset
2208 call writefile(lines, 'XscriptPropsWithText')
057c26b5c33a patch 9.0.0067: cannot show virtual text
Bram Moolenaar <Bram@vim.org>
parents: 28984
diff changeset
2209 let buf = RunVimInTerminal('-S XscriptPropsWithText', #{rows: 6, cols: 60})
29550
ec5f48ab361b patch 9.0.0116: virtual text not displayed if 'signcolumn' is "yes"
Bram Moolenaar <Bram@vim.org>
parents: 29451
diff changeset
2210 call VerifyScreenDump(buf, 'Test_prop_inserts_text_1', {})
ec5f48ab361b patch 9.0.0116: virtual text not displayed if 'signcolumn' is "yes"
Bram Moolenaar <Bram@vim.org>
parents: 29451
diff changeset
2211
ec5f48ab361b patch 9.0.0116: virtual text not displayed if 'signcolumn' is "yes"
Bram Moolenaar <Bram@vim.org>
parents: 29451
diff changeset
2212 call term_sendkeys(buf, ":set signcolumn=yes\<CR>")
ec5f48ab361b patch 9.0.0116: virtual text not displayed if 'signcolumn' is "yes"
Bram Moolenaar <Bram@vim.org>
parents: 29451
diff changeset
2213 call VerifyScreenDump(buf, 'Test_prop_inserts_text_2', {})
29451
057c26b5c33a patch 9.0.0067: cannot show virtual text
Bram Moolenaar <Bram@vim.org>
parents: 28984
diff changeset
2214
057c26b5c33a patch 9.0.0067: cannot show virtual text
Bram Moolenaar <Bram@vim.org>
parents: 28984
diff changeset
2215 call StopVimInTerminal(buf)
057c26b5c33a patch 9.0.0067: cannot show virtual text
Bram Moolenaar <Bram@vim.org>
parents: 28984
diff changeset
2216 call delete('XscriptPropsWithText')
057c26b5c33a patch 9.0.0067: cannot show virtual text
Bram Moolenaar <Bram@vim.org>
parents: 28984
diff changeset
2217 endfunc
057c26b5c33a patch 9.0.0067: cannot show virtual text
Bram Moolenaar <Bram@vim.org>
parents: 28984
diff changeset
2218
29560
14b139cbec49 patch 9.0.0121: cannot put virtual text after or below a line
Bram Moolenaar <Bram@vim.org>
parents: 29552
diff changeset
2219 func Test_props_with_text_after()
14b139cbec49 patch 9.0.0121: cannot put virtual text after or below a line
Bram Moolenaar <Bram@vim.org>
parents: 29552
diff changeset
2220 CheckRunVimInTerminal
14b139cbec49 patch 9.0.0121: cannot put virtual text after or below a line
Bram Moolenaar <Bram@vim.org>
parents: 29552
diff changeset
2221
14b139cbec49 patch 9.0.0121: cannot put virtual text after or below a line
Bram Moolenaar <Bram@vim.org>
parents: 29552
diff changeset
2222 let lines =<< trim END
14b139cbec49 patch 9.0.0121: cannot put virtual text after or below a line
Bram Moolenaar <Bram@vim.org>
parents: 29552
diff changeset
2223 call setline(1, 'some text here and other text there')
14b139cbec49 patch 9.0.0121: cannot put virtual text after or below a line
Bram Moolenaar <Bram@vim.org>
parents: 29552
diff changeset
2224 call prop_type_add('rightprop', #{highlight: 'ErrorMsg'})
14b139cbec49 patch 9.0.0121: cannot put virtual text after or below a line
Bram Moolenaar <Bram@vim.org>
parents: 29552
diff changeset
2225 call prop_type_add('afterprop', #{highlight: 'Search'})
14b139cbec49 patch 9.0.0121: cannot put virtual text after or below a line
Bram Moolenaar <Bram@vim.org>
parents: 29552
diff changeset
2226 call prop_type_add('belowprop', #{highlight: 'DiffAdd'})
14b139cbec49 patch 9.0.0121: cannot put virtual text after or below a line
Bram Moolenaar <Bram@vim.org>
parents: 29552
diff changeset
2227 call prop_add(1, 0, #{type: 'rightprop', text: ' RIGHT ', text_align: 'right'})
29581
4a79bca8a76e patch 9.0.0131: virtual text with Tab is not displayed correctly
Bram Moolenaar <Bram@vim.org>
parents: 29579
diff changeset
2228 call prop_add(1, 0, #{type: 'afterprop', text: "\tAFTER\t", text_align: 'after'})
29560
14b139cbec49 patch 9.0.0121: cannot put virtual text after or below a line
Bram Moolenaar <Bram@vim.org>
parents: 29552
diff changeset
2229 call prop_add(1, 0, #{type: 'belowprop', text: ' BELOW ', text_align: 'below'})
29568
8f71840ecf07 patch 9.0.0125: cursor positioned wrong with virtual text after the line
Bram Moolenaar <Bram@vim.org>
parents: 29560
diff changeset
2230
8f71840ecf07 patch 9.0.0125: cursor positioned wrong with virtual text after the line
Bram Moolenaar <Bram@vim.org>
parents: 29560
diff changeset
2231 call setline(2, 'Last line.')
8f71840ecf07 patch 9.0.0125: cursor positioned wrong with virtual text after the line
Bram Moolenaar <Bram@vim.org>
parents: 29560
diff changeset
2232 call prop_add(2, 0, #{type: 'afterprop', text: ' After Last ', text_align: 'after'})
8f71840ecf07 patch 9.0.0125: cursor positioned wrong with virtual text after the line
Bram Moolenaar <Bram@vim.org>
parents: 29560
diff changeset
2233 normal G$
29583
32aee589fc9a patch 9.0.0132: multi-byte characters in virtual text not handled correctly
Bram Moolenaar <Bram@vim.org>
parents: 29581
diff changeset
2234
32aee589fc9a patch 9.0.0132: multi-byte characters in virtual text not handled correctly
Bram Moolenaar <Bram@vim.org>
parents: 29581
diff changeset
2235 call setline(3, 'right here')
32aee589fc9a patch 9.0.0132: multi-byte characters in virtual text not handled correctly
Bram Moolenaar <Bram@vim.org>
parents: 29581
diff changeset
2236 call prop_add(3, 0, #{type: 'rightprop', text: 'söme和平téxt', text_align: 'right'})
29560
14b139cbec49 patch 9.0.0121: cannot put virtual text after or below a line
Bram Moolenaar <Bram@vim.org>
parents: 29552
diff changeset
2237 END
14b139cbec49 patch 9.0.0121: cannot put virtual text after or below a line
Bram Moolenaar <Bram@vim.org>
parents: 29552
diff changeset
2238 call writefile(lines, 'XscriptPropsWithTextAfter')
14b139cbec49 patch 9.0.0121: cannot put virtual text after or below a line
Bram Moolenaar <Bram@vim.org>
parents: 29552
diff changeset
2239 let buf = RunVimInTerminal('-S XscriptPropsWithTextAfter', #{rows: 6, cols: 60})
14b139cbec49 patch 9.0.0121: cannot put virtual text after or below a line
Bram Moolenaar <Bram@vim.org>
parents: 29552
diff changeset
2240 call VerifyScreenDump(buf, 'Test_prop_with_text_after_1', {})
14b139cbec49 patch 9.0.0121: cannot put virtual text after or below a line
Bram Moolenaar <Bram@vim.org>
parents: 29552
diff changeset
2241
14b139cbec49 patch 9.0.0121: cannot put virtual text after or below a line
Bram Moolenaar <Bram@vim.org>
parents: 29552
diff changeset
2242 call StopVimInTerminal(buf)
14b139cbec49 patch 9.0.0121: cannot put virtual text after or below a line
Bram Moolenaar <Bram@vim.org>
parents: 29552
diff changeset
2243 call delete('XscriptPropsWithTextAfter')
14b139cbec49 patch 9.0.0121: cannot put virtual text after or below a line
Bram Moolenaar <Bram@vim.org>
parents: 29552
diff changeset
2244 endfunc
14b139cbec49 patch 9.0.0121: cannot put virtual text after or below a line
Bram Moolenaar <Bram@vim.org>
parents: 29552
diff changeset
2245
29552
89a97f70e8eb patch 9.0.0117: text of removed textprop with text is not freed
Bram Moolenaar <Bram@vim.org>
parents: 29550
diff changeset
2246 func Test_removed_prop_with_text_cleans_up_array()
89a97f70e8eb patch 9.0.0117: text of removed textprop with text is not freed
Bram Moolenaar <Bram@vim.org>
parents: 29550
diff changeset
2247 new
89a97f70e8eb patch 9.0.0117: text of removed textprop with text is not freed
Bram Moolenaar <Bram@vim.org>
parents: 29550
diff changeset
2248 call setline(1, 'some text here')
89a97f70e8eb patch 9.0.0117: text of removed textprop with text is not freed
Bram Moolenaar <Bram@vim.org>
parents: 29550
diff changeset
2249 call prop_type_add('some', #{highlight: 'ErrorMsg'})
89a97f70e8eb patch 9.0.0117: text of removed textprop with text is not freed
Bram Moolenaar <Bram@vim.org>
parents: 29550
diff changeset
2250 let id1 = prop_add(1, 5, #{type: 'some', text: "SOME"})
89a97f70e8eb patch 9.0.0117: text of removed textprop with text is not freed
Bram Moolenaar <Bram@vim.org>
parents: 29550
diff changeset
2251 call assert_equal(-1, id1)
89a97f70e8eb patch 9.0.0117: text of removed textprop with text is not freed
Bram Moolenaar <Bram@vim.org>
parents: 29550
diff changeset
2252 let id2 = prop_add(1, 10, #{type: 'some', text: "HERE"})
89a97f70e8eb patch 9.0.0117: text of removed textprop with text is not freed
Bram Moolenaar <Bram@vim.org>
parents: 29550
diff changeset
2253 call assert_equal(-2, id2)
89a97f70e8eb patch 9.0.0117: text of removed textprop with text is not freed
Bram Moolenaar <Bram@vim.org>
parents: 29550
diff changeset
2254
89a97f70e8eb patch 9.0.0117: text of removed textprop with text is not freed
Bram Moolenaar <Bram@vim.org>
parents: 29550
diff changeset
2255 " removing the props resets the index
89a97f70e8eb patch 9.0.0117: text of removed textprop with text is not freed
Bram Moolenaar <Bram@vim.org>
parents: 29550
diff changeset
2256 call prop_remove(#{id: id1})
89a97f70e8eb patch 9.0.0117: text of removed textprop with text is not freed
Bram Moolenaar <Bram@vim.org>
parents: 29550
diff changeset
2257 call prop_remove(#{id: id2})
89a97f70e8eb patch 9.0.0117: text of removed textprop with text is not freed
Bram Moolenaar <Bram@vim.org>
parents: 29550
diff changeset
2258 let id1 = prop_add(1, 5, #{type: 'some', text: "SOME"})
89a97f70e8eb patch 9.0.0117: text of removed textprop with text is not freed
Bram Moolenaar <Bram@vim.org>
parents: 29550
diff changeset
2259 call assert_equal(-1, id1)
89a97f70e8eb patch 9.0.0117: text of removed textprop with text is not freed
Bram Moolenaar <Bram@vim.org>
parents: 29550
diff changeset
2260
89a97f70e8eb patch 9.0.0117: text of removed textprop with text is not freed
Bram Moolenaar <Bram@vim.org>
parents: 29550
diff changeset
2261 call prop_type_delete('some')
89a97f70e8eb patch 9.0.0117: text of removed textprop with text is not freed
Bram Moolenaar <Bram@vim.org>
parents: 29550
diff changeset
2262 bwipe!
89a97f70e8eb patch 9.0.0117: text of removed textprop with text is not freed
Bram Moolenaar <Bram@vim.org>
parents: 29550
diff changeset
2263 endfunc
89a97f70e8eb patch 9.0.0117: text of removed textprop with text is not freed
Bram Moolenaar <Bram@vim.org>
parents: 29550
diff changeset
2264
29579
f7a64755dbe9 patch 9.0.0130: cursor position wrong when inserting around virtual text
Bram Moolenaar <Bram@vim.org>
parents: 29568
diff changeset
2265 def Test_insert_text_before_virtual_text()
f7a64755dbe9 patch 9.0.0130: cursor position wrong when inserting around virtual text
Bram Moolenaar <Bram@vim.org>
parents: 29568
diff changeset
2266 new foobar
f7a64755dbe9 patch 9.0.0130: cursor position wrong when inserting around virtual text
Bram Moolenaar <Bram@vim.org>
parents: 29568
diff changeset
2267 setline(1, '12345678')
f7a64755dbe9 patch 9.0.0130: cursor position wrong when inserting around virtual text
Bram Moolenaar <Bram@vim.org>
parents: 29568
diff changeset
2268 prop_type_add('test', {highlight: 'Search'})
f7a64755dbe9 patch 9.0.0130: cursor position wrong when inserting around virtual text
Bram Moolenaar <Bram@vim.org>
parents: 29568
diff changeset
2269 prop_add(1, 5, {
f7a64755dbe9 patch 9.0.0130: cursor position wrong when inserting around virtual text
Bram Moolenaar <Bram@vim.org>
parents: 29568
diff changeset
2270 type: 'test',
f7a64755dbe9 patch 9.0.0130: cursor position wrong when inserting around virtual text
Bram Moolenaar <Bram@vim.org>
parents: 29568
diff changeset
2271 text: ' virtual text '
f7a64755dbe9 patch 9.0.0130: cursor position wrong when inserting around virtual text
Bram Moolenaar <Bram@vim.org>
parents: 29568
diff changeset
2272 })
f7a64755dbe9 patch 9.0.0130: cursor position wrong when inserting around virtual text
Bram Moolenaar <Bram@vim.org>
parents: 29568
diff changeset
2273 normal! f4axyz
f7a64755dbe9 patch 9.0.0130: cursor position wrong when inserting around virtual text
Bram Moolenaar <Bram@vim.org>
parents: 29568
diff changeset
2274 normal! f5iXYZ
f7a64755dbe9 patch 9.0.0130: cursor position wrong when inserting around virtual text
Bram Moolenaar <Bram@vim.org>
parents: 29568
diff changeset
2275 assert_equal('1234xyzXYZ5678', getline(1))
f7a64755dbe9 patch 9.0.0130: cursor position wrong when inserting around virtual text
Bram Moolenaar <Bram@vim.org>
parents: 29568
diff changeset
2276
f7a64755dbe9 patch 9.0.0130: cursor position wrong when inserting around virtual text
Bram Moolenaar <Bram@vim.org>
parents: 29568
diff changeset
2277 prop_type_delete('test')
f7a64755dbe9 patch 9.0.0130: cursor position wrong when inserting around virtual text
Bram Moolenaar <Bram@vim.org>
parents: 29568
diff changeset
2278 bwipe!
f7a64755dbe9 patch 9.0.0130: cursor position wrong when inserting around virtual text
Bram Moolenaar <Bram@vim.org>
parents: 29568
diff changeset
2279 enddef
f7a64755dbe9 patch 9.0.0130: cursor position wrong when inserting around virtual text
Bram Moolenaar <Bram@vim.org>
parents: 29568
diff changeset
2280
20178
2fb397573541 patch 8.2.0644: insufficient testing for invalid function arguments
Bram Moolenaar <Bram@vim.org>
parents: 19642
diff changeset
2281 " vim: shiftwidth=2 sts=2 expandtab