Patch 9.0.0194
Problem:    Cursor displayed in wrong position after removing text prop. (Ben
            Jackson)
Solution:   Invalidate the cursor position. (closes #10898)
Files:      src/move.c, src/proto/move.pro, src/change.c, src/textprop.c,
            src/testdir/test_textprop.vim,
            src/testdir/dumps/Test_prop_with_text_cursormoved_1.dump,
            src/testdir/dumps/Test_prop_with_text_cursormoved_2.dump


*** ../vim-9.0.0193/src/move.c  2022-06-24 12:34:48.000000000 +0100
--- src/move.c  2022-08-12 12:51:10.829898098 +0100
***************
*** 594,599 ****
--- 594,615 ----
  }
  
  /*
+  * Display of line has changed for "buf", invalidate cursor position and
+  * w_botline.
+  */
+     void
+ changed_line_display_buf(buf_T *buf)
+ {
+     win_T *wp;
+ 
+     FOR_ALL_WINDOWS(wp)
+       if (wp->w_buffer == buf)
+           wp->w_valid &= ~(VALID_WROW|VALID_WCOL|VALID_VIRTCOL
+                               |VALID_CROW|VALID_CHEIGHT
+                               |VALID_TOPLINE|VALID_BOTLINE|VALID_BOTLINE_AP);
+ }
+ 
+ /*
   * Make sure the value of curwin->w_botline is valid.
   */
      void
*** ../vim-9.0.0193/src/proto/move.pro  2022-06-27 23:15:16.000000000 +0100
--- src/proto/move.pro  2022-08-12 12:51:13.189888979 +0100
***************
*** 11,16 ****
--- 11,17 ----
  void changed_cline_bef_curs_win(win_T *wp);
  void changed_line_abv_curs(void);
  void changed_line_abv_curs_win(win_T *wp);
+ void changed_line_display_buf(buf_T *buf);
  void validate_botline(void);
  void validate_botline_win(win_T *wp);
  void invalidate_botline(void);
*** ../vim-9.0.0193/src/change.c        2022-08-08 15:49:14.188114984 +0100
--- src/change.c        2022-08-12 12:51:44.805768527 +0100
***************
*** 801,806 ****
--- 801,807 ----
  
  /*
   * Marks the area to be redrawn after a change.
+  * Consider also calling changed_line_display_buf().
   */
      void
  changed_lines_buf(
*** ../vim-9.0.0193/src/textprop.c      2022-08-10 19:50:44.113894645 +0100
--- src/textprop.c      2022-08-12 12:52:14.145659505 +0100
***************
*** 310,315 ****
--- 310,316 ----
        buf->b_ml.ml_flags |= ML_LINE_DIRTY;
      }
  
+     changed_line_display_buf(buf);
      changed_lines_buf(buf, start_lnum, end_lnum + 1, 0);
      res = OK;
  
***************
*** 1507,1512 ****
--- 1508,1514 ----
  
      if (first_changed > 0)
      {
+       changed_line_display_buf(buf);
        changed_lines_buf(buf, first_changed, last_changed + 1, 0);
        redraw_buf_later(buf, VALID);
      }
*** ../vim-9.0.0193/src/testdir/test_textprop.vim       2022-08-11 
17:24:27.481795141 +0100
--- src/testdir/test_textprop.vim       2022-08-12 13:01:09.187996820 +0100
***************
*** 2775,2780 ****
--- 2775,2819 ----
    call delete('XscriptPropsBelowNowrap')
  endfunc
  
+ func Test_props_with_text_CursorMoved()
+   CheckRunVimInTerminal
+ 
+   let lines =<< trim END
+       call setline(1, ['this is line one', 'this is line two', 'three', 
'four', 'five'])
+ 
+       call prop_type_add('prop', #{highlight: 'Error'})
+       let g:long_text = repeat('x', &columns * 2)
+ 
+       let g:prop_id = v:null
+       func! Update()
+         if line('.') == 1
+           if g:prop_id == v:null
+             let g:prop_id = prop_add(1, 0, #{type: 'prop', text_wrap: 'wrap', 
text: g:long_text})
+           endif
+         elseif g:prop_id != v:null
+           call prop_remove(#{id: g:prop_id})
+           let g:prop_id = v:null
+         endif
+       endfunc
+ 
+       autocmd CursorMoved * call Update()
+   END
+   call writefile(lines, 'XscriptPropsCursorMovec')
+   let buf = RunVimInTerminal('-S XscriptPropsCursorMovec', #{rows: 8, cols: 
60})
+   call term_sendkeys(buf, "gg0w")
+   call VerifyScreenDump(buf, 'Test_prop_with_text_cursormoved_1', {})
+ 
+   call term_sendkeys(buf, "j")
+   call VerifyScreenDump(buf, 'Test_prop_with_text_cursormoved_2', {})
+ 
+   " back to the first state
+   call term_sendkeys(buf, "k")
+   call VerifyScreenDump(buf, 'Test_prop_with_text_cursormoved_1', {})
+ 
+   call StopVimInTerminal(buf)
+   call delete('XscriptPropsCursorMovec')
+ endfunc
+ 
  func Test_props_with_text_after_split_join()
    CheckRunVimInTerminal
  
*** ../vim-9.0.0193/src/testdir/dumps/Test_prop_with_text_cursormoved_1.dump    
2022-08-12 13:03:28.935627519 +0100
--- src/testdir/dumps/Test_prop_with_text_cursormoved_1.dump    2022-08-12 
13:01:18.827970762 +0100
***************
*** 0 ****
--- 1,8 ----
+ |t+0&#ffffff0|h|i|s| >i|s| |l|i|n|e| |o|n|e|x+0#ffffff16#ff404010@43
+ @60
+ @16| +0#0000000#ffffff0@43
+ |t|h|i|s| |i|s| |l|i|n|e| |t|w|o| @43
+ |t|h|r|e@1| @54
+ |f|o|u|r| @55
+ |f|i|v|e| @55
+ @42|1|,|6| @10|A|l@1| 
*** ../vim-9.0.0193/src/testdir/dumps/Test_prop_with_text_cursormoved_2.dump    
2022-08-12 13:05:04.759383358 +0100
--- src/testdir/dumps/Test_prop_with_text_cursormoved_2.dump    2022-08-12 
13:01:17.675973872 +0100
***************
*** 0 ****
--- 1,8 ----
+ |t+0&#ffffff0|h|i|s| |i|s| |l|i|n|e| |o|n|e| @43
+ |t|h|i|s| >i|s| |l|i|n|e| |t|w|o| @43
+ |t|h|r|e@1| @54
+ |f|o|u|r| @55
+ |f|i|v|e| @55
+ |~+0#4040ff13&| @58
+ |~| @58
+ | +0#0000000&@41|2|,|6| @10|A|l@1| 
*** ../vim-9.0.0193/src/version.c       2022-08-11 17:24:27.485795172 +0100
--- src/version.c       2022-08-12 12:48:46.702493234 +0100
***************
*** 737,738 ****
--- 737,740 ----
  {   /* Add new patch number below this line */
+ /**/
+     194,
  /**/

-- 
TALL KNIGHT OF NI: Ni!
                 "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD

 /// Bram Moolenaar -- b...@moolenaar.net -- 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 vim_dev+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_dev/20220812120753.98B681C0823%40moolenaar.net.

Raspunde prin e-mail lui