aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/screen.c
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2022-03-23 11:30:02 +0800
committerzeertzjq <zeertzjq@outlook.com>2022-03-24 16:08:59 +0800
commit3e9b4e917d0783d0414192c3ad231cfcb813e73f (patch)
tree5e95003eea2e5076fa8db2efdcbf3970302a66bc /src/nvim/screen.c
parenta72f338d76c871869712518df862c85d1df25f54 (diff)
downloadrneovim-3e9b4e917d0783d0414192c3ad231cfcb813e73f.tar.gz
rneovim-3e9b4e917d0783d0414192c3ad231cfcb813e73f.tar.bz2
rneovim-3e9b4e917d0783d0414192c3ad231cfcb813e73f.zip
vim-patch:8.2.4591: cursor line not updated when a callback moves the cursor
Problem: Cursor line not updated when a callback moves the cursor. Solution: Check if the cursor moved. (closes vim/vim#9970) https://github.com/vim/vim/commit/e7a74d53754765f22ef8ce71c915bb669d5f7f3f redraw_after_callback() is N/A. Nvim handles timers on the main loop.
Diffstat (limited to 'src/nvim/screen.c')
-rw-r--r--src/nvim/screen.c17
1 files changed, 16 insertions, 1 deletions
diff --git a/src/nvim/screen.c b/src/nvim/screen.c
index 0194149b1b..27011c6f1e 100644
--- a/src/nvim/screen.c
+++ b/src/nvim/screen.c
@@ -737,6 +737,9 @@ static void win_update(win_T *wp, DecorProviders *providers)
#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;
linenr_T mod_top = 0;
linenr_T mod_bot = 0;
int save_got_int;
@@ -1368,7 +1371,7 @@ static void win_update(win_T *wp, DecorProviders *providers)
|| (wp->w_match_head != NULL
&& buf->b_mod_xlines != 0)))))
|| (wp->w_p_cul && (lnum == wp->w_cursor.lnum
- || lnum == wp->w_last_cursorline))) {
+ || lnum == last_cursorline))) {
if (lnum == mod_top) {
top_to_mod = false;
}
@@ -7615,3 +7618,15 @@ win_T *get_win_by_grid_handle(handle_T handle)
return NULL;
}
+/// 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(curwin, VALID);
+ }
+}