Patch 8.2.4944
Problem:    Text properties are wrong after "cc". (Axel Forsman)
Solution:   Pass the deleted byte count to inserted_bytes(). (closes #10412,
            closes #7737, closes #5763)
Files:      src/change.c, src/testdir/test_textprop.vim


*** ../vim-8.2.4943/src/change.c        2022-05-07 20:01:10.050731702 +0100
--- src/change.c        2022-05-12 18:42:54.782574588 +0100
***************
*** 2349,2359 ****
      char_u    *newp;
      linenr_T  lnum = curwin->w_cursor.lnum;
      colnr_T   col = curwin->w_cursor.col;
  
      if (col == 0)
        newp = vim_strsave((char_u *)"");
      else
!       newp = vim_strnsave(ml_get(lnum), col);
  
      if (newp == NULL)
        return FAIL;
--- 2349,2363 ----
      char_u    *newp;
      linenr_T  lnum = curwin->w_cursor.lnum;
      colnr_T   col = curwin->w_cursor.col;
+     char_u    *old_line;
+     int               deleted;
  
+     old_line = ml_get(lnum);
      if (col == 0)
        newp = vim_strsave((char_u *)"");
      else
!       newp = vim_strnsave(old_line, col);
!     deleted = (int)STRLEN(old_line) - col;
  
      if (newp == NULL)
        return FAIL;
***************
*** 2361,2367 ****
      ml_replace(lnum, newp, FALSE);
  
      // mark the buffer as changed and prepare for displaying
!     changed_bytes(lnum, curwin->w_cursor.col);
  
      // If "fixpos" is TRUE we don't want to end up positioned at the NUL.
      if (fixpos && curwin->w_cursor.col > 0)
--- 2365,2371 ----
      ml_replace(lnum, newp, FALSE);
  
      // mark the buffer as changed and prepare for displaying
!     inserted_bytes(lnum, curwin->w_cursor.col, -deleted);
  
      // If "fixpos" is TRUE we don't want to end up positioned at the NUL.
      if (fixpos && curwin->w_cursor.col > 0)
*** ../vim-8.2.4943/src/testdir/test_textprop.vim       2022-04-18 
21:53:59.090171080 +0100
--- src/testdir/test_textprop.vim       2022-05-12 18:30:56.042801270 +0100
***************
*** 534,539 ****
--- 534,557 ----
    set bs&
  endfunc
  
+ func Test_prop_change()
+   new
+   let expected = SetupOneLine() " 'xonex xtwoxx'
+ 
+   " Characterwise.
+   exe "normal 7|c$\<Esc>"
+   call assert_equal('xonex ', getline(1))
+   call assert_equal(expected[:0], prop_list(1))
+   " Linewise.
+   exe "normal cc\<Esc>"
+   call assert_equal('', getline(1))
+   call assert_equal([], prop_list(1))
+ 
+   call DeletePropTypes()
+   bwipe!
+   set bs&
+ endfunc
+ 
  func Test_prop_replace()
    new
    set bs=2
*** ../vim-8.2.4943/src/version.c       2022-05-12 17:44:25.819076137 +0100
--- src/version.c       2022-05-12 18:33:08.786759252 +0100
***************
*** 748,749 ****
--- 748,751 ----
  {   /* Add new patch number below this line */
+ /**/
+     4944,
  /**/

-- 
Rule #1: Don't give somebody a tool that he's going to hurt himself with.

 /// 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/20220512174553.C439E1C1EE1%40moolenaar.net.

Raspunde prin e-mail lui