comparison src/testdir/test_textprop.vim @ 16662:1fc9cd08cf3c v8.1.1333

patch 8.1.1333: text properties don't always move after changes commit https://github.com/vim/vim/commit/45dd07f10af9bea86f8df77e92788209e209fdab Author: Bram Moolenaar <Bram@vim.org> Date: Wed May 15 22:45:37 2019 +0200 patch 8.1.1333: text properties don't always move after changes Problem: Text properties don't always move after changes. Solution: Update properties before reporting changes to listeners. Move text property when splitting a line.
author Bram Moolenaar <Bram@vim.org>
date Wed, 15 May 2019 23:00:15 +0200
parents 7a563ee902b6
children 5733d8e33bce
comparison
equal deleted inserted replaced
16661:0e9c064b096c 16662:1fc9cd08cf3c
149 bwipe! 149 bwipe!
150 endfunc 150 endfunc
151 151
152 func SetupOneLine() 152 func SetupOneLine()
153 call setline(1, 'xonex xtwoxx') 153 call setline(1, 'xonex xtwoxx')
154 normal gg0
154 call AddPropTypes() 155 call AddPropTypes()
155 call prop_add(1, 2, {'length': 3, 'id': 11, 'type': 'one'}) 156 call prop_add(1, 2, {'length': 3, 'id': 11, 'type': 'one'})
156 call prop_add(1, 8, {'length': 3, 'id': 12, 'type': 'two'}) 157 call prop_add(1, 8, {'length': 3, 'id': 12, 'type': 'two'})
157 let expected = [ 158 let expected = [
158 \ {'col': 2, 'length': 3, 'id': 11, 'type': 'one', 'start': 1, 'end': 1}, 159 \ {'col': 2, 'length': 3, 'id': 11, 'type': 'one', 'start': 1, 'end': 1},
266 exe "normal 0foRyy\<BS>\<BS>" 267 exe "normal 0foRyy\<BS>\<BS>"
267 call assert_equal('yyyex xyyoxx', getline(1)) 268 call assert_equal('yyyex xyyoxx', getline(1))
268 call assert_equal(expected, prop_list(1)) 269 call assert_equal(expected, prop_list(1))
269 270
270 call DeletePropTypes() 271 call DeletePropTypes()
272 bwipe!
273 set bs&
274 endfunc
275
276 func Test_prop_open_line()
277 new
278
279 " open new line, props stay in top line
280 let expected = SetupOneLine() " 'xonex xtwoxx'
281 exe "normal o\<Esc>"
282 call assert_equal('xonex xtwoxx', getline(1))
283 call assert_equal('', getline(2))
284 call assert_equal(expected, prop_list(1))
285 call DeletePropTypes()
286
287 " move all props to next line
288 let expected = SetupOneLine() " 'xonex xtwoxx'
289 exe "normal 0i\<CR>\<Esc>"
290 call assert_equal('', getline(1))
291 call assert_equal('xonex xtwoxx', getline(2))
292 call assert_equal(expected, prop_list(2))
293 call DeletePropTypes()
294
295 " split just before prop, move all props to next line
296 let expected = SetupOneLine() " 'xonex xtwoxx'
297 exe "normal 0li\<CR>\<Esc>"
298 call assert_equal('x', getline(1))
299 call assert_equal('onex xtwoxx', getline(2))
300 let expected[0].col -= 1
301 let expected[1].col -= 1
302 call assert_equal(expected, prop_list(2))
303 call DeletePropTypes()
304
305 " split inside prop, split first prop
306 let expected = SetupOneLine() " 'xonex xtwoxx'
307 exe "normal 0lli\<CR>\<Esc>"
308 call assert_equal('xo', getline(1))
309 call assert_equal('nex xtwoxx', getline(2))
310 let exp_first = [deepcopy(expected[0])]
311 let exp_first[0].length = 1
312 call assert_equal(exp_first, prop_list(1))
313 let expected[0].col = 1
314 let expected[0].length = 2
315 let expected[1].col -= 2
316 call assert_equal(expected, prop_list(2))
317 call DeletePropTypes()
318
319 " split just after first prop, empty prop and second prop move to next line
320 let expected = SetupOneLine() " 'xonex xtwoxx'
321 exe "normal 0fea\<CR>\<Esc>"
322 call assert_equal('xone', getline(1))
323 call assert_equal('x xtwoxx', getline(2))
324 let exp_first = expected[0:0]
325 call assert_equal(exp_first, prop_list(1))
326 let expected[0].col = 1
327 let expected[0].length = 0
328 let expected[1].col -= 4
329 call assert_equal(expected, prop_list(2))
330 call DeletePropTypes()
331
271 bwipe! 332 bwipe!
272 set bs& 333 set bs&
273 endfunc 334 endfunc
274 335
275 func Test_prop_clear() 336 func Test_prop_clear()