Patch 8.2.3372
Problem:    line2byte() value wrong when adding a text property. (Yuto Kimura)
Solution:   Adjust length for text property. (closes #8772)  Also fix it for
            deleting a line.
Files:      src/memline.c, src/testdir/test_textprop.vim


*** ../vim-8.2.3371/src/memline.c       2021-08-16 21:15:28.215345122 +0200
--- src/memline.c       2021-08-25 16:38:42.927482363 +0200
***************
*** 3251,3259 ****
--- 3251,3265 ----
      }
  
  #ifdef FEAT_BYTEOFF
+ # ifdef FEAT_PROP_POPUP
+     if (curbuf->b_has_textprop)
+       // only use the space needed for the text, ignore properties
+       len = (colnr_T)STRLEN(line) + 1;
+ # endif
      // The line was inserted below 'lnum'
      ml_updatechunk(buf, lnum + 1, (long)len, ML_CHNK_ADDLINE);
  #endif
+ 
  #ifdef FEAT_NETBEANS_INTG
      if (netbeans_active())
      {
***************
*** 3752,3758 ****
      }
  
  #ifdef FEAT_BYTEOFF
!     ml_updatechunk(buf, lnum, line_size, ML_CHNK_DELLINE);
  #endif
      ret = OK;
  
--- 3758,3768 ----
      }
  
  #ifdef FEAT_BYTEOFF
!     ml_updatechunk(buf, lnum, line_size
! # ifdef FEAT_PROP_POPUP
!                                       - textprop_save_len
! # endif
!                                                           , ML_CHNK_DELLINE);
  #endif
      ret = OK;
  
*** ../vim-8.2.3371/src/testdir/test_textprop.vim       2021-08-16 
21:38:38.131122584 +0200
--- src/testdir/test_textprop.vim       2021-08-25 16:38:08.427561909 +0200
***************
*** 857,862 ****
--- 857,871 ----
    call assert_equal(1491, line2byte(401))
    bwipe!
  
+   new
+   call setline(1, range(520))
+   call assert_equal(1491, line2byte(401))
+   call prop_add(2, 1, {'type': 'comment'})
+   call assert_equal(1491, line2byte(401))
+   2delete
+   call assert_equal(1489, line2byte(400))
+   bwipe!
+ 
    call prop_type_delete('comment')
  endfunc
  
*** ../vim-8.2.3371/src/version.c       2021-08-24 21:55:58.337276558 +0200
--- src/version.c       2021-08-25 16:31:14.360541232 +0200
***************
*** 757,758 ****
--- 757,760 ----
  {   /* Add new patch number below this line */
+ /**/
+     3372,
  /**/

-- 
System administrators are just like women: You can't live with them and you
can't live without them.

 /// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net   \\\
///                                                                      \\\
\\\        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ ///
 \\\            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].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_dev/202108251440.17PEevcf2226888%40masaka.moolenaar.net.

Raspunde prin e-mail lui