@@ -348,6 +348,59 @@ func Test_prop_byteoff()
348348 call prop_type_delete (' comment' )
349349endfunc
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+ 1 d
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
352405funct Test_textprop_screenshots ()
353406 if ! CanRunVimInTerminal () || &encoding != ' utf-8'
0 commit comments