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\<c-v>$o$A\<bs>\<esc>"
+   "call feedkeys("Vj\<c-v>$o$A\<bs>\<esc>", '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 -- [email protected] -- 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    ///

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Raspunde prin e-mail lui