Skip to content

Commit 7f1664e

Browse files
committed
patch 8.1.0689: undo with text properties not tested
Problem: Undo with text properties not tested. Solution: Add a test function.
1 parent ccae467 commit 7f1664e

2 files changed

Lines changed: 55 additions & 0 deletions

File tree

src/testdir/test_textprop.vim

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -348,6 +348,59 @@ func Test_prop_byteoff()
348348
call prop_type_delete('comment')
349349
endfunc
350350

351+
func Test_prop_undo()
352+
new
353+
call prop_type_add('comment', {'highlight': 'Directory'})
354+
call setline(1, ['oneone', 'twotwo', 'three'])
355+
" Set 'undolevels' to break changes into undo-able pieces.
356+
set ul&
357+
358+
call prop_add(1, 3, {'end_col': 5, 'type': 'comment'})
359+
let expected = [{'col': 3, 'length': 2, 'id': 0, 'type': 'comment', 'start': 1, 'end': 1} ]
360+
call assert_equal(expected, prop_list(1))
361+
362+
" Insert a character, then undo.
363+
exe "normal 0lllix\<Esc>"
364+
set ul&
365+
let expected[0].length = 3
366+
call assert_equal(expected, prop_list(1))
367+
undo
368+
let expected[0].length = 2
369+
call assert_equal(expected, prop_list(1))
370+
371+
" Delete a character, then undo
372+
exe "normal 0lllx"
373+
set ul&
374+
let expected[0].length = 1
375+
call assert_equal(expected, prop_list(1))
376+
undo
377+
let expected[0].length = 2
378+
call assert_equal(expected, prop_list(1))
379+
380+
" Delete the line, then undo
381+
1d
382+
set ul&
383+
call assert_equal([], prop_list(1))
384+
undo
385+
call assert_equal(expected, prop_list(1))
386+
387+
" Insert a character, delete two characters, then undo with "U"
388+
exe "normal 0lllix\<Esc>"
389+
set ul&
390+
let expected[0].length = 3
391+
call assert_equal(expected, prop_list(1))
392+
exe "normal 0lllxx"
393+
set ul&
394+
let expected[0].length = 1
395+
call assert_equal(expected, prop_list(1))
396+
normal U
397+
let expected[0].length = 2
398+
call assert_equal(expected, prop_list(1))
399+
400+
bwipe!
401+
call prop_type_delete('comment')
402+
endfunc
403+
351404
" screenshot test with textprop highlighting
352405
funct Test_textprop_screenshots()
353406
if !CanRunVimInTerminal() || &encoding != 'utf-8'

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -799,6 +799,8 @@ static char *(features[]) =
799799

800800
static int included_patches[] =
801801
{ /* Add new patch number below this line */
802+
/**/
803+
689,
802804
/**/
803805
688,
804806
/**/

0 commit comments

Comments
 (0)