To: vim_dev@googlegroups.com Subject: Patch 8.0.1575 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.0.1575 Problem: Crash when using virtual replace. Solution: Adjust orig_line_count. Add more tests. (Christian Brabandt) Files: src/edit.c, src/testdir/test_visual.vim *** ../vim-8.0.1574/src/edit.c 2018-03-04 20:14:08.240064393 +0100 --- src/edit.c 2018-03-06 12:05:11.051771382 +0100 *************** *** 8907,8913 **** --- 8907,8923 ---- || do_join(2, FALSE, TRUE, FALSE, FALSE) == FAIL) vim_beep(BO_BS); else + { curwin->w_cursor.col = temp; + #ifdef FEAT_VREPLACE + /* Adjust orig_line_count in case more lines have been deleted than + * have been added. That makes sure, that open_line() later + * can access all buffer lines correctly */ + if (State & VREPLACE_FLAG && + orig_line_count > curbuf->b_ml.ml_line_count) + orig_line_count = curbuf->b_ml.ml_line_count; + #endif + } } else if (del_char(FALSE) == FAIL) /* delete char under cursor */ vim_beep(BO_BS); *** ../vim-8.0.1574/src/testdir/test_visual.vim 2017-10-26 20:20:27.321598241 +0200 --- src/testdir/test_visual.vim 2018-03-06 12:10:35.169845781 +0100 *************** *** 70,82 **** exe "normal \" catch /^Vim\%((\a\+)\)\=:E315/ echom 'Snap! E315 error!' ! let g:msg='Snap! E315 error!' endtry endfunc func Test_visual_mode_reset() enew ! let g:msg="Everything's fine." enew setl buftype=nofile call append(line('$'), 'Delete this line.') --- 70,82 ---- exe "normal \" catch /^Vim\%((\a\+)\)\=:E315/ echom 'Snap! E315 error!' ! let g:msg = 'Snap! E315 error!' endtry endfunc func Test_visual_mode_reset() enew ! let g:msg = "Everything's fine." enew setl buftype=nofile call append(line('$'), 'Delete this line.') *************** *** 186,189 **** --- 186,244 ---- call assert_equal(['AB......CDEFGHI.Jkl', \ 'AB IJKLMNO QRst'], getline(12, 13)) enew! + set noai bs&vim t_kD&vim t_kb&vim + endfunc + + " Test Virtual replace mode. + func Test_virtual_replace2() + enew! + set bs=2 + exe "normal a\nabcdefghi\njk\tlmn\n opq rst\n\uvwxyz" + call cursor(1,1) + " Test 1: Test that del deletes the newline + exe "normal gR0\ 1\nA\nBCDEFGHIJ\n\tKL\nMNO\nPQR" + call assert_equal(['0 1', + \ 'A', + \ 'BCDEFGHIJ', + \ ' KL', + \ 'MNO', + \ 'PQR', + \ ], getline(1, 6)) + " Test 2: + " a newline is not deleted, if no newline has been added in virtual replace mode + %d_ + call setline(1, ['abcd', 'efgh', 'ijkl']) + call cursor(2,1) + exe "norm! gR1234\5\\\" + call assert_equal(['abcd', + \ '123h', + \ 'ijkl'], getline(1, '$')) + " Test 3: + " a newline is deleted, if a newline has been inserted before in virtual replace mode + %d_ + call setline(1, ['abcd', 'efgh', 'ijkl']) + call cursor(2,1) + exe "norm! gR1234\\56\\\" + call assert_equal(['abcd', + \ '1234', + \ 'ijkl'], getline(1, '$')) + " Test 4: + " delete add a newline, delete it, add it again and check undo + %d_ + call setline(1, ['abcd', 'efgh', 'ijkl']) + call cursor(2,1) + " break undo sequence explicitly + let &ul = &ul + exe "norm! gR1234\\\56\" + let &ul = &ul + call assert_equal(['abcd', + \ '123456', + \ ''], getline(1, '$')) + norm! u + call assert_equal(['abcd', + \ 'efgh', + \ 'ijkl'], getline(1, '$')) + " clean up + %d_ + set bs&vim endfunc *** ../vim-8.0.1574/src/version.c 2018-03-06 11:43:00.327652783 +0100 --- src/version.c 2018-03-06 12:06:14.187396329 +0100 *************** *** 768,769 **** --- 768,771 ---- { /* Add new patch number below this line */ + /**/ + 1575, /**/ -- Hanson's Treatment of Time: There are never enough hours in a day, but always too many days before Saturday. /// 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 ///