To: vim_dev@googlegroups.com Subject: Patch 8.2.0109 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.2.0109 Problem: Corrupted text properties when expanding spaces. Solution: Reallocate the line. (Nobuhiro Takasaki, closes #5457) Files: src/edit.c, src/testdir/test_textprop.vim *** ../vim-8.2.0108/src/edit.c 2020-01-03 21:25:55.325995770 +0100 --- src/edit.c 2020-01-09 21:31:52.521454110 +0100 *************** *** 5604,5612 **** #ifdef FEAT_PROP_POPUP if (!(State & VREPLACE_FLAG)) { ! mch_memmove(ptr, ptr + i, curbuf->b_ml.ml_line_len - i ! - (ptr - curbuf->b_ml.ml_line_ptr)); curbuf->b_ml.ml_line_len -= i; } else #endif --- 5604,5628 ---- #ifdef FEAT_PROP_POPUP if (!(State & VREPLACE_FLAG)) { ! char_u *newp; ! int col; ! ! newp = alloc(curbuf->b_ml.ml_line_len - i); ! if (newp == NULL) ! return FALSE; ! ! col = ptr - curbuf->b_ml.ml_line_ptr; ! if (col > 0) ! mch_memmove(newp, ptr - col, col); ! mch_memmove(newp + col, ptr + i, ! curbuf->b_ml.ml_line_len - col - i); ! ! if (curbuf->b_ml.ml_flags & ML_LINE_DIRTY) ! vim_free(curbuf->b_ml.ml_line_ptr); ! curbuf->b_ml.ml_line_ptr = newp; curbuf->b_ml.ml_line_len -= i; + curbuf->b_ml.ml_flags = + (curbuf->b_ml.ml_flags | ML_LINE_DIRTY) & ~ML_EMPTY; } else #endif *** ../vim-8.2.0108/src/testdir/test_textprop.vim 2020-01-03 21:25:55.325995770 +0100 --- src/testdir/test_textprop.vim 2020-01-09 21:15:23.325724554 +0100 *************** *** 926,944 **** bwipe! endfunc func Test_textprop_noexpandtab() - %bwipe! new ! let save_ts = &tabstop set tabstop=8 - let save_sts = &softtabstop set softtabstop=4 - let save_sw = &shiftwidth set shiftwidth=4 - let save_et = &expandtab set noexpandtab - let save_fdm = &foldmethod set foldmethod=marker call feedkeys("\\0Ca\\\", "tx") call prop_type_add('test', {'highlight': 'ErrorMsg'}) call prop_add(1, 1, {'end_col': 2, 'type': 'test'}) --- 926,957 ---- bwipe! endfunc + func SaveOptions() + let d = #{tabstop: &tabstop, + \ softtabstop: &softtabstop, + \ shiftwidth: &shiftwidth, + \ expandtab: &expandtab, + \ foldmethod: '"' .. &foldmethod .. '"', + \ } + return d + endfunc + + func RestoreOptions(dict) + for name in keys(a:dict) + exe 'let &' .. name .. ' = ' .. a:dict[name] + endfor + endfunc + func Test_textprop_noexpandtab() new ! let save_dict = SaveOptions() ! set tabstop=8 set softtabstop=4 set shiftwidth=4 set noexpandtab set foldmethod=marker + call feedkeys("\\0Ca\\\", "tx") call prop_type_add('test', {'highlight': 'ErrorMsg'}) call prop_add(1, 1, {'end_col': 2, 'type': 'test'}) *************** *** 955,963 **** catch /^Vim\%((\a\+)\)\=:E964/ endtry call prop_remove({'type': 'test'}) ! let &foldmethod = save_fdm ! let &expandtab = save_et ! let &shiftwidth = save_sw ! let &softtabstop = save_sts ! let &tabstop = save_ts endfunc --- 968,1018 ---- catch /^Vim\%((\a\+)\)\=:E964/ endtry call prop_remove({'type': 'test'}) ! call prop_type_delete('test') ! ! call RestoreOptions(save_dict) ! bwipe! ! endfunc ! ! func Test_textprop_noexpandtab_redraw() ! new ! let save_dict = SaveOptions() ! ! set tabstop=8 ! set softtabstop=4 ! set shiftwidth=4 ! set noexpandtab ! set foldmethod=marker ! ! call feedkeys("\\0Ca\\\\", "tx") ! call prop_type_add('test', {'highlight': 'ErrorMsg'}) ! call prop_add(1, 1, {'end_col': 2, 'type': 'test'}) ! call feedkeys("0i\", "tx") ! " Internally broken at the next line ! call feedkeys("A\\", "tx") ! redraw ! " Index calculation failed internally on next line ! call prop_add(1, 1, {'end_col': 2, 'type': 'test'}) ! call prop_remove({'type': 'test', 'all': v:true}) ! call prop_type_delete('test') ! call prop_type_delete('test') ! ! call RestoreOptions(save_dict) ! bwipe! ! endfunc ! ! func Test_textprop_ins_str() ! new ! call setline(1, 'just some text') ! call prop_type_add('test', {'highlight': 'ErrorMsg'}) ! call prop_add(1, 1, {'end_col': 2, 'type': 'test'}) ! call assert_equal([{'id': 0, 'col': 1, 'end': 1, 'type': 'test', 'length': 1, 'start': 1}], prop_list(1)) ! ! call feedkeys("foi\\", "tx") ! call assert_equal('just some text', getline(1)) ! call assert_equal([{'id': 0, 'col': 1, 'end': 1, 'type': 'test', 'length': 1, 'start': 1}], prop_list(1)) ! ! bwipe! ! call prop_remove({'type': 'test'}) ! call prop_type_delete('test') endfunc *** ../vim-8.2.0108/src/version.c 2020-01-09 21:01:32.552829739 +0100 --- src/version.c 2020-01-09 21:33:24.149062192 +0100 *************** *** 744,745 **** --- 744,747 ---- { /* Add new patch number below this line */ + /**/ + 109, /**/ -- Violators can be fined, arrested or jailed for making ugly faces at a dog. [real standing law in Oklahoma, United States of America] /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\ \\\ an exciting new programming language -- http://www.Zimbu.org /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///