@@ -926,19 +926,32 @@ func Test_proptype_substitute2()
926926 bwipe!
927927endfunc
928928
929+ func SaveOptions ()
930+ let d = #{tabstop : &tabstop ,
931+ \ softtabstop : &softtabstop ,
932+ \ shiftwidth : &shiftwidth ,
933+ \ expandtab : &expandtab ,
934+ \ foldmethod : ' "' .. &foldmethod .. ' "' ,
935+ \ }
936+ return d
937+ endfunc
938+
939+ func RestoreOptions (dict )
940+ for name in keys (a: dict )
941+ exe ' let &' .. name .. ' = ' .. a: dict [name]
942+ endfor
943+ endfunc
944+
929945func Test_textprop_noexpandtab ()
930- % bwipe!
931946 new
932- let save_ts = &tabstop
947+ let save_dict = SaveOptions ()
948+
933949 set tabstop = 8
934- let save_sts = &softtabstop
935950 set softtabstop = 4
936- let save_sw = &shiftwidth
937951 set shiftwidth = 4
938- let save_et = &expandtab
939952 set noexpandtab
940- let save_fdm = &foldmethod
941953 set foldmethod = marker
954+
942955 call feedkeys (" \<esc>\<esc> 0Ca\<cr>\<esc>\<up> " , " tx" )
943956 call prop_type_add (' test' , {' highlight' : ' ErrorMsg' })
944957 call prop_add (1 , 1 , {' end_col' : 2 , ' type' : ' test' })
@@ -955,9 +968,51 @@ func Test_textprop_noexpandtab()
955968 catch /^Vim\%((\a\+)\)\=:E964/
956969 endtry
957970 call prop_remove ({' type' : ' test' })
958- let &foldmethod = save_fdm
959- let &expandtab = save_et
960- let &shiftwidth = save_sw
961- let &softtabstop = save_sts
962- let &tabstop = save_ts
971+ call prop_type_delete (' test' )
972+
973+ call RestoreOptions (save_dict)
974+ bwipe!
975+ endfunc
976+
977+ func Test_textprop_noexpandtab_redraw ()
978+ new
979+ let save_dict = SaveOptions ()
980+
981+ set tabstop = 8
982+ set softtabstop = 4
983+ set shiftwidth = 4
984+ set noexpandtab
985+ set foldmethod = marker
986+
987+ call feedkeys (" \<esc>\<esc> 0Ca\<cr>\<space>\<esc>\<up> " , " tx" )
988+ call prop_type_add (' test' , {' highlight' : ' ErrorMsg' })
989+ call prop_add (1 , 1 , {' end_col' : 2 , ' type' : ' test' })
990+ call feedkeys (" 0i\<tab> " , " tx" )
991+ " Internally broken at the next line
992+ call feedkeys (" A\<left>\<tab> " , " tx" )
993+ redraw
994+ " Index calculation failed internally on next line
995+ call prop_add (1 , 1 , {' end_col' : 2 , ' type' : ' test' })
996+ call prop_remove ({' type' : ' test' , ' all' : v: true })
997+ call prop_type_delete (' test' )
998+ call prop_type_delete (' test' )
999+
1000+ call RestoreOptions (save_dict)
1001+ bwipe!
1002+ endfunc
1003+
1004+ func Test_textprop_ins_str ()
1005+ new
1006+ call setline (1 , ' just some text' )
1007+ call prop_type_add (' test' , {' highlight' : ' ErrorMsg' })
1008+ call prop_add (1 , 1 , {' end_col' : 2 , ' type' : ' test' })
1009+ call assert_equal ([{' id' : 0 , ' col' : 1 , ' end' : 1 , ' type' : ' test' , ' length' : 1 , ' start' : 1 }], prop_list (1 ))
1010+
1011+ call feedkeys (" foi\<F8>\<Esc> " , " tx" )
1012+ call assert_equal (' just s<F8>ome text' , getline (1 ))
1013+ call assert_equal ([{' id' : 0 , ' col' : 1 , ' end' : 1 , ' type' : ' test' , ' length' : 1 , ' start' : 1 }], prop_list (1 ))
1014+
1015+ bwipe!
1016+ call prop_remove ({' type' : ' test' })
1017+ call prop_type_delete (' test' )
9631018endfunc
0 commit comments