Patch 8.2.4591
Problem: Cursor line not updated when a callback moves the cursor.
Solution: Check if the cursor moved. (closes #9970)
Files: src/main.c, src/drawscreen.c, src/proto/drawscreen.pro,
src/testdir/test_cursorline.vim,
src/testdir/dumps/Test_cursorline_callback_1.dump
*** ../vim-8.2.4590/src/main.c 2022-02-07 10:45:12.799027338 +0000
--- src/main.c 2022-03-19 10:28:02.827123400 +0000
***************
*** 1386,1397 ****
#ifdef FEAT_SYN_HL
// Might need to update for 'cursorline'.
! // When 'cursorlineopt' is "screenline" need to redraw always.
! if (curwin->w_p_cul
! && (curwin->w_last_cursorline != curwin->w_cursor.lnum
! || (curwin->w_p_culopt_flags & CULOPT_SCRLINE))
! && !char_avail())
! redraw_later(VALID);
#endif
if (VIsual_active)
update_curbuf(INVERTED); // update inverted part
--- 1386,1392 ----
#ifdef FEAT_SYN_HL
// Might need to update for 'cursorline'.
! check_redraw_cursorline();
#endif
if (VIsual_active)
update_curbuf(INVERTED); // update inverted part
*** ../vim-8.2.4590/src/drawscreen.c 2022-02-16 19:24:03.618162413 +0000
--- src/drawscreen.c 2022-03-19 11:08:37.504059993 +0000
***************
*** 1463,1473 ****
#ifdef FEAT_SYN_HL
// remember what happened to the previous line, to know if
// check_visual_highlight() can be used
! #define DID_NONE 1 // didn't update a line
! #define DID_LINE 2 // updated a normal line
! #define DID_FOLD 3 // updated a folded line
int did_update = DID_NONE;
linenr_T syntax_last_parsed = 0; // last parsed text line
#endif
linenr_T mod_top = 0;
linenr_T mod_bot = 0;
--- 1463,1476 ----
#ifdef FEAT_SYN_HL
// remember what happened to the previous line, to know if
// check_visual_highlight() can be used
! # define DID_NONE 1 // didn't update a line
! # define DID_LINE 2 // updated a normal line
! # define DID_FOLD 3 // updated a folded line
int did_update = DID_NONE;
linenr_T syntax_last_parsed = 0; // last parsed text line
+ // remember the current w_last_cursorline, it changes when drawing the new
+ // cursor line
+ linenr_T last_cursorline = wp->w_last_cursorline;
#endif
linenr_T mod_top = 0;
linenr_T mod_bot = 0;
***************
*** 2244,2250 ****
))))
#ifdef FEAT_SYN_HL
|| (wp->w_p_cul && (lnum == wp->w_cursor.lnum
! || lnum == wp->w_last_cursorline))
#endif
)
{
--- 2247,2253 ----
))))
#ifdef FEAT_SYN_HL
|| (wp->w_p_cul && (lnum == wp->w_cursor.lnum
! || lnum == last_cursorline))
#endif
)
{
***************
*** 3027,3032 ****
--- 3030,3052 ----
}
#endif
+ #if defined(FEAT_SYN_HL) || defined(PROTO)
+ /*
+ * Check if the cursor moved and 'cursorline' is set. Mark for a VALID redraw
+ * if needed.
+ */
+ void
+ check_redraw_cursorline(void)
+ {
+ // When 'cursorlineopt' is "screenline" need to redraw always.
+ if (curwin->w_p_cul
+ && (curwin->w_last_cursorline != curwin->w_cursor.lnum
+ || (curwin->w_p_culopt_flags & CULOPT_SCRLINE))
+ && !char_avail())
+ redraw_later(VALID);
+ }
+ #endif
+
/*
* Invoked after an asynchronous callback is called.
* If an echo command was used the cursor needs to be put back where
***************
*** 3071,3076 ****
--- 3091,3100 ----
}
else if (State & (NORMAL | INSERT | TERMINAL))
{
+ #ifdef FEAT_SYN_HL
+ // might need to update for 'cursorline'
+ check_redraw_cursorline();
+ #endif
// keep the command line if possible
update_screen(VALID_NO_UPDATE);
setcursor();
*** ../vim-8.2.4590/src/proto/drawscreen.pro 2021-12-09 10:50:48.566865615
+0000
--- src/proto/drawscreen.pro 2022-03-19 10:42:44.704940869 +0000
***************
*** 8,13 ****
--- 8,14 ----
void update_debug_sign(buf_T *buf, linenr_T lnum);
void updateWindow(win_T *wp);
int redraw_asap(int type);
+ void check_redraw_cursorline(void);
void redraw_after_callback(int call_update_screen, int do_message);
void redraw_later(int type);
void redraw_win_later(win_T *wp, int type);
*** ../vim-8.2.4590/src/testdir/test_cursorline.vim 2022-02-10
19:51:42.545569904 +0000
--- src/testdir/test_cursorline.vim 2022-03-19 11:05:42.328868001 +0000
***************
*** 247,250 ****
--- 247,276 ----
call delete('Xtextfile')
endfunc
+ func Test_cursorline_callback()
+ CheckScreendump
+ CheckFeature timers
+
+ let lines =<< trim END
+ call setline(1, ['aaaaa', 'bbbbb', 'ccccc', 'ddddd'])
+ set cursorline
+ call cursor(4, 1)
+
+ func Func(timer)
+ call cursor(2, 1)
+ endfunc
+
+ call timer_start(300, 'Func')
+ END
+ call writefile(lines, 'Xcul_timer')
+
+ let buf = RunVimInTerminal('-S Xcul_timer', #{rows: 8})
+ call TermWait(buf, 310)
+ call VerifyScreenDump(buf, 'Test_cursorline_callback_1', {})
+
+ call StopVimInTerminal(buf)
+ call delete('Xcul_timer')
+ endfunc
+
+
" vim: shiftwidth=2 sts=2 expandtab
*** ../vim-8.2.4590/src/testdir/dumps/Test_cursorline_callback_1.dump
2022-03-19 11:09:13.427901313 +0000
--- src/testdir/dumps/Test_cursorline_callback_1.dump 2022-03-19
11:05:59.760784736 +0000
***************
*** 0 ****
--- 1,8 ----
+ |a+0&#ffffff0@4| @69
+ >b+8&&@4| @69
+ |c+0&&@4| @69
+ |d@4| @69
+ |~+0#4040ff13&| @73
+ |~| @73
+ |~| @73
+ | +0#0000000&@56|4|,|1| @10|A|l@1|
*** ../vim-8.2.4590/src/version.c 2022-03-18 21:41:43.816964266 +0000
--- src/version.c 2022-03-19 10:29:31.602911371 +0000
***************
*** 752,753 ****
--- 752,755 ----
{ /* Add new patch number below this line */
+ /**/
+ 4591,
/**/
--
DINGO: Wicked wicked Zoot ... she is a bad person and she must pay the
penalty. And here in Castle Anthrax, we have but one punishment
... you must tie her down on a bed ... and spank her. Come!
GIRLS: A spanking! A spanking!
"Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD
/// 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/20220319111105.DAA691C13D6%40moolenaar.net.