Patch 8.1.2294
Problem:    Cursor position wrong when characters are concealed and asearch
            causes a scroll.
Solution:   Fix the cursor column in a concealed line after window scroll.
            (closes #5215, closes #5012)
Files:      src/drawscreen.c, src/testdir/test_matchadd_conceal.vim


*** ../vim-8.1.2293/src/drawscreen.c    2019-11-10 17:22:26.948204460 +0100
--- src/drawscreen.c    2019-11-12 20:46:16.089889768 +0100
***************
*** 1398,1404 ****
      int               i;
      long      j;
      static int        recursive = FALSE;      // being called recursively
!     int               old_botline = wp->w_botline;
  #ifdef FEAT_FOLDING
      long      fold_count;
  #endif
--- 1398,1408 ----
      int               i;
      long      j;
      static int        recursive = FALSE;      // being called recursively
!     linenr_T  old_botline = wp->w_botline;
! #ifdef FEAT_CONCEAL
!     int               old_wrow = wp->w_wrow;
!     int               old_wcol = wp->w_wcol;
! #endif
  #ifdef FEAT_FOLDING
      long      fold_count;
  #endif
***************
*** 2567,2584 ****
        wp->w_valid |= VALID_BOTLINE;
        if (wp == curwin && wp->w_botline != old_botline && !recursive)
        {
            recursive = TRUE;
            curwin->w_valid &= ~VALID_TOPLINE;
            update_topline();   // may invalidate w_botline again
!           if (must_redraw != 0)
            {
                // Don't update for changes in buffer again.
                i = curbuf->b_mod_set;
                curbuf->b_mod_set = FALSE;
                win_update(curwin);
-               must_redraw = 0;
                curbuf->b_mod_set = i;
            }
            recursive = FALSE;
        }
      }
--- 2571,2622 ----
        wp->w_valid |= VALID_BOTLINE;
        if (wp == curwin && wp->w_botline != old_botline && !recursive)
        {
+           win_T       *wwp;
+ #if defined(FEAT_CONCEAL)
+           linenr_T    old_topline = wp->w_topline;
+           int         new_wcol = wp->w_wcol;
+ #endif
            recursive = TRUE;
            curwin->w_valid &= ~VALID_TOPLINE;
            update_topline();   // may invalidate w_botline again
! 
! #if defined(FEAT_CONCEAL)
!           if (old_wcol != new_wcol && (wp->w_valid & (VALID_WCOL|VALID_WROW))
!                                                   != (VALID_WCOL|VALID_WROW))
!           {
!               // A win_line() call applied a fix to screen cursor column to
!               // accomodate concealment of cursor line, but in this call to
!               // update_topline() the cursor's row or column got invalidated.
!               // If they are left invalid, setcursor() will recompute them
!               // but there won't be any further win_line() call to re-fix the
!               // column and the cursor will end up misplaced.  So we call
!               // cursor validation now and reapply the fix again (or call
!               // win_line() to do it for us).
!               validate_cursor();
!               if (wp->w_wcol == old_wcol && wp->w_wrow == old_wrow
!                                              && old_topline == wp->w_topline)
!                   wp->w_wcol = new_wcol;
!               else
!                   redrawWinline(wp, wp->w_cursor.lnum);
!           }
! #endif
!           // New redraw either due to updated topline or due to wcol fix.
!           if (wp->w_redr_type != 0)
            {
                // Don't update for changes in buffer again.
                i = curbuf->b_mod_set;
                curbuf->b_mod_set = FALSE;
+               j = curbuf->b_mod_xlines;
+               curbuf->b_mod_xlines = 0;
                win_update(curwin);
                curbuf->b_mod_set = i;
+               curbuf->b_mod_xlines = j;
            }
+           // Other windows might have w_redr_type raised in update_topline().
+           must_redraw = 0;
+           FOR_ALL_WINDOWS(wwp)
+               if (wwp->w_redr_type > must_redraw)
+                   must_redraw = wwp->w_redr_type;
            recursive = FALSE;
        }
      }
*** ../vim-8.1.2293/src/testdir/test_matchadd_conceal.vim       2019-06-15 
17:57:43.972724036 +0200
--- src/testdir/test_matchadd_conceal.vim       2019-11-12 20:39:00.003426140 
+0100
***************
*** 8,13 ****
--- 8,15 ----
  endif
  
  source shared.vim
+ source term_util.vim
+ source view_util.vim
  
  func Test_simple_matchadd()
    new
***************
*** 277,279 ****
--- 279,318 ----
    call assert_notequal(screenattr(1, 11) , screenattr(1, 12))
    call assert_equal(screenattr(1, 11) , screenattr(1, 32))
  endfunc
+ 
+ func Test_cursor_column_in_concealed_line_after_window_scroll()
+   CheckRunVimInTerminal
+ 
+   " Test for issue #5012 fix.
+   " For a concealed line with cursor, there should be no window's cursor
+   " position invalidation during win_update() after scrolling attempt that is
+   " not successful and no real topline change happens. The invalidation would
+   " cause a window's cursor position recalc outside of win_line() where it's
+   " not possible to take conceal into account.
+   let lines =<< trim END
+     3split
+     let m = matchadd('Conceal', '=')
+     setl conceallevel=2 concealcursor=nc
+     normal gg
+     "==expr==
+   END
+   call writefile(lines, 'Xcolesearch')
+   let buf = RunVimInTerminal('Xcolesearch', {})
+ 
+   " Jump to something that is beyond the bottom of the window,
+   " so there's a scroll down.
+   call term_sendkeys(buf, ":so %\<CR>")
+   call term_sendkeys(buf, "/expr\<CR>")
+   call term_wait(buf)
+ 
+   " Are the concealed parts of the current line really hidden?
+   let cursor_row = term_scrape(buf, '.')->map({_, e -> e.chars})->join('')
+   call assert_equal('"expr', cursor_row)
+ 
+   " BugFix check: Is the window's cursor column properly updated for hidden
+   " parts of the current line?
+   call assert_equal(2, term_getcursor(buf)[1])
+ 
+   call StopVimInTerminal(buf)
+   call delete('Xcolesearch')
+ endfunc
*** ../vim-8.1.2293/src/version.c       2019-11-12 20:31:16.568776952 +0100
--- src/version.c       2019-11-12 20:42:48.806639644 +0100
***************
*** 743,744 ****
--- 743,746 ----
  {   /* Add new patch number below this line */
+ /**/
+     2294,
  /**/

-- 
hundred-and-one symptoms of being an internet addict:
80. At parties, you introduce your spouse as your "service provider."

 /// 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].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_dev/201911121949.xACJnjME020722%40masaka.moolenaar.net.

Raspunde prin e-mail lui