To: vim_dev@googlegroups.com Subject: Patch 8.0.1779 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.0.1779 Problem: Deleting in a block selection causes problems. Solution: Check the length of the line before adding bd.textcol and bd.textlen. (Christian Brabandt, closes #2825) Files: src/ops.c, src/testdir/test_blockedit.vim *** ../vim-8.0.1778/src/ops.c 2018-04-10 13:15:24.965054405 +0200 --- src/ops.c 2018-04-30 14:09:57.923029049 +0200 *************** *** 2703,2708 **** --- 2703,2710 ---- { struct block_def bd2; int did_indent = FALSE; + size_t len; + int add; /* If indent kicked in, the firstline might have changed * but only do that, if the indent actually increased. */ *************** *** 2781,2789 **** * Subsequent calls to ml_get() flush the firstline data - take a * copy of the required string. */ ! firstline = ml_get(oap->start.lnum) + bd.textcol; if (oap->op_type == OP_APPEND) ! firstline += bd.textlen; if (pre_textlen >= 0 && (ins_len = (long)STRLEN(firstline) - pre_textlen) > 0) { --- 2783,2797 ---- * Subsequent calls to ml_get() flush the firstline data - take a * copy of the required string. */ ! firstline = ml_get(oap->start.lnum); ! len = STRLEN(firstline); ! add = bd.textcol; if (oap->op_type == OP_APPEND) ! add += bd.textlen; ! if ((size_t)add > len) ! firstline += len; // short line, point to the NUL ! else ! firstline += add; if (pre_textlen >= 0 && (ins_len = (long)STRLEN(firstline) - pre_textlen) > 0) { *** ../vim-8.0.1778/src/testdir/test_blockedit.vim 2018-04-10 13:15:24.961054433 +0200 --- src/testdir/test_blockedit.vim 2018-04-30 16:52:26.275603260 +0200 *************** *** 16,20 **** --- 16,33 ---- bwipe! endfunc + func Test_blockinsert_delete() + new + let _bs = &bs + set bs=2 + call setline(1, ['case Arg is ', ' when Name_Async,', ' when Name_Num_Gangs,', 'end if;']) + exe "norm! ggjVj\$o$A\\" + "call feedkeys("Vj\$o$A\\", 'ti') + call assert_equal(["case Arg is ", " when Name_Async", " when Name_Num_Gangs,", "end if;"], + \ getline(1,'$')) + " reset to sane state + let &bs = _bs + bwipe! + endfunc " vim: shiftwidth=2 sts=2 expandtab *** ../vim-8.0.1778/src/version.c 2018-04-30 15:44:21.164299549 +0200 --- src/version.c 2018-04-30 16:55:07.698638748 +0200 *************** *** 763,764 **** --- 763,766 ---- { /* Add new patch number below this line */ + /**/ + 1779, /**/ -- Not too long ago, unzipping in public was illegal... /// 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 ///