comparison src/testdir/test_textprop.vim @ 19097:bcbc9fe665b5 v8.2.0109

patch 8.2.0109: corrupted text properties when expanding spaces Commit: https://github.com/vim/vim/commit/ac15fd8c6761763c8feedef1a2fbd8309f0a823c Author: Bram Moolenaar <Bram@vim.org> Date: Thu Jan 9 21:35:48 2020 +0100 patch 8.2.0109: corrupted text properties when expanding spaces Problem: Corrupted text properties when expanding spaces. Solution: Reallocate the line. (Nobuhiro Takasaki, closes https://github.com/vim/vim/issues/5457)
author Bram Moolenaar <Bram@vim.org>
date Thu, 09 Jan 2020 21:45:03 +0100
parents 143d44d8f477
children 91bb12995034
comparison
equal deleted inserted replaced
19096:af8bd2f486b6 19097:bcbc9fe665b5
924 let expected = [{'id': 0, 'col': 10, 'end': 1, 'type': 'number', 'length': 3, 'start': 1}] 924 let expected = [{'id': 0, 'col': 10, 'end': 1, 'type': 'number', 'length': 3, 'start': 1}]
925 call assert_equal(expected, prop_list(1)) 925 call assert_equal(expected, prop_list(1))
926 bwipe! 926 bwipe!
927 endfunc 927 endfunc
928 928
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
929 func Test_textprop_noexpandtab() 945 func Test_textprop_noexpandtab()
930 %bwipe! 946 new
931 new 947 let save_dict = SaveOptions()
932 let save_ts = &tabstop 948
933 set tabstop=8 949 set tabstop=8
934 let save_sts = &softtabstop
935 set softtabstop=4 950 set softtabstop=4
936 let save_sw = &shiftwidth
937 set shiftwidth=4 951 set shiftwidth=4
938 let save_et = &expandtab
939 set noexpandtab 952 set noexpandtab
940 let save_fdm = &foldmethod
941 set foldmethod=marker 953 set foldmethod=marker
954
942 call feedkeys("\<esc>\<esc>0Ca\<cr>\<esc>\<up>", "tx") 955 call feedkeys("\<esc>\<esc>0Ca\<cr>\<esc>\<up>", "tx")
943 call prop_type_add('test', {'highlight': 'ErrorMsg'}) 956 call prop_type_add('test', {'highlight': 'ErrorMsg'})
944 call prop_add(1, 1, {'end_col': 2, 'type': 'test'}) 957 call prop_add(1, 1, {'end_col': 2, 'type': 'test'})
945 call feedkeys("0i\<tab>", "tx") 958 call feedkeys("0i\<tab>", "tx")
946 call prop_remove({'type': 'test'}) 959 call prop_remove({'type': 'test'})
953 " Has already collapsed here, start_col:6 does not result in an error 966 " Has already collapsed here, start_col:6 does not result in an error
954 call feedkeys("A\<left>\<tab>", "tx") 967 call feedkeys("A\<left>\<tab>", "tx")
955 catch /^Vim\%((\a\+)\)\=:E964/ 968 catch /^Vim\%((\a\+)\)\=:E964/
956 endtry 969 endtry
957 call prop_remove({'type': 'test'}) 970 call prop_remove({'type': 'test'})
958 let &foldmethod = save_fdm 971 call prop_type_delete('test')
959 let &expandtab = save_et 972
960 let &shiftwidth = save_sw 973 call RestoreOptions(save_dict)
961 let &softtabstop = save_sts 974 bwipe!
962 let &tabstop = save_ts 975 endfunc
963 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')
1018 endfunc