Mercurial > vim
comparison src/testdir/test_textprop.vim @ 16060:176872829dc2 v8.1.1035
patch 8.1.1035: prop_remove() second argument is not optional
commit https://github.com/vim/vim/commit/0a2f578e22de7e4d82075578afdd5fc2d2dd8134
Author: Bram Moolenaar <Bram@vim.org>
Date: Fri Mar 22 13:20:43 2019 +0100
patch 8.1.1035: prop_remove() second argument is not optional
Problem: prop_remove() second argument is not optional.
Solution: Fix argument count. Use "buf" instead of "curbuf". (closes https://github.com/vim/vim/issues/4147)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Fri, 22 Mar 2019 13:30:05 +0100 |
parents | 857ce36c8412 |
children | 7a563ee902b6 |
comparison
equal
deleted
inserted
replaced
16059:f9b1e3a7ffcc | 16060:176872829dc2 |
---|---|
164 | 164 |
165 func Test_prop_add_remove_buf() | 165 func Test_prop_add_remove_buf() |
166 new | 166 new |
167 let bufnr = bufnr('') | 167 let bufnr = bufnr('') |
168 call AddPropTypes() | 168 call AddPropTypes() |
169 call setline(1, 'one two three') | 169 for lnum in range(1, 4) |
170 call setline(lnum, 'one two three') | |
171 endfor | |
170 wincmd w | 172 wincmd w |
171 call prop_add(1, 1, {'length': 3, 'id': 11, 'type': 'one', 'bufnr': bufnr}) | 173 for lnum in range(1, 4) |
172 call prop_add(1, 5, {'length': 3, 'id': 12, 'type': 'two', 'bufnr': bufnr}) | 174 call prop_add(lnum, 1, {'length': 3, 'id': 11, 'type': 'one', 'bufnr': bufnr}) |
173 call prop_add(1, 11, {'length': 3, 'id': 13, 'type': 'three', 'bufnr': bufnr}) | 175 call prop_add(lnum, 5, {'length': 3, 'id': 12, 'type': 'two', 'bufnr': bufnr}) |
174 | 176 call prop_add(lnum, 11, {'length': 3, 'id': 13, 'type': 'three', 'bufnr': bufnr}) |
177 endfor | |
178 | |
175 let props = [ | 179 let props = [ |
176 \ {'col': 1, 'length': 3, 'id': 11, 'type': 'one', 'start': 1, 'end': 1}, | 180 \ {'col': 1, 'length': 3, 'id': 11, 'type': 'one', 'start': 1, 'end': 1}, |
177 \ {'col': 5, 'length': 3, 'id': 12, 'type': 'two', 'start': 1, 'end': 1}, | 181 \ {'col': 5, 'length': 3, 'id': 12, 'type': 'two', 'start': 1, 'end': 1}, |
178 \ {'col': 11, 'length': 3, 'id': 13, 'type': 'three', 'start': 1, 'end': 1}, | 182 \ {'col': 11, 'length': 3, 'id': 13, 'type': 'three', 'start': 1, 'end': 1}, |
179 \] | 183 \] |
180 call assert_equal(props, prop_list(1, {'bufnr': bufnr})) | 184 call assert_equal(props, prop_list(1, {'bufnr': bufnr})) |
181 | 185 |
182 " remove by id | 186 " remove by id |
187 let before_props = deepcopy(props) | |
188 unlet props[1] | |
189 | |
183 call prop_remove({'id': 12, 'bufnr': bufnr}, 1) | 190 call prop_remove({'id': 12, 'bufnr': bufnr}, 1) |
184 unlet props[1] | |
185 call assert_equal(props, prop_list(1, {'bufnr': bufnr})) | 191 call assert_equal(props, prop_list(1, {'bufnr': bufnr})) |
192 call assert_equal(before_props, prop_list(2, {'bufnr': bufnr})) | |
193 call assert_equal(before_props, prop_list(3, {'bufnr': bufnr})) | |
194 call assert_equal(before_props, prop_list(4, {'bufnr': bufnr})) | |
195 | |
196 call prop_remove({'id': 12, 'bufnr': bufnr}, 3, 4) | |
197 call assert_equal(props, prop_list(1, {'bufnr': bufnr})) | |
198 call assert_equal(before_props, prop_list(2, {'bufnr': bufnr})) | |
199 call assert_equal(props, prop_list(3, {'bufnr': bufnr})) | |
200 call assert_equal(props, prop_list(4, {'bufnr': bufnr})) | |
201 | |
202 call prop_remove({'id': 12, 'bufnr': bufnr}) | |
203 for lnum in range(1, 4) | |
204 call assert_equal(props, prop_list(lnum, {'bufnr': bufnr})) | |
205 endfor | |
186 | 206 |
187 " remove by type | 207 " remove by type |
208 let before_props = deepcopy(props) | |
209 unlet props[0] | |
210 | |
188 call prop_remove({'type': 'one', 'bufnr': bufnr}, 1) | 211 call prop_remove({'type': 'one', 'bufnr': bufnr}, 1) |
189 unlet props[0] | |
190 call assert_equal(props, prop_list(1, {'bufnr': bufnr})) | 212 call assert_equal(props, prop_list(1, {'bufnr': bufnr})) |
213 call assert_equal(before_props, prop_list(2, {'bufnr': bufnr})) | |
214 call assert_equal(before_props, prop_list(3, {'bufnr': bufnr})) | |
215 call assert_equal(before_props, prop_list(4, {'bufnr': bufnr})) | |
216 | |
217 call prop_remove({'type': 'one', 'bufnr': bufnr}, 3, 4) | |
218 call assert_equal(props, prop_list(1, {'bufnr': bufnr})) | |
219 call assert_equal(before_props, prop_list(2, {'bufnr': bufnr})) | |
220 call assert_equal(props, prop_list(3, {'bufnr': bufnr})) | |
221 call assert_equal(props, prop_list(4, {'bufnr': bufnr})) | |
222 | |
223 call prop_remove({'type': 'one', 'bufnr': bufnr}) | |
224 for lnum in range(1, 4) | |
225 call assert_equal(props, prop_list(lnum, {'bufnr': bufnr})) | |
226 endfor | |
191 | 227 |
192 call DeletePropTypes() | 228 call DeletePropTypes() |
193 wincmd w | 229 wincmd w |
194 bwipe! | 230 bwipe! |
195 endfunc | 231 endfunc |