Mercurial > vim
comparison src/drawscreen.c @ 28133:373f1afadfa3 v8.2.4591
patch 8.2.4591: cursor line not updated when a callback moves the cursor
Commit: https://github.com/vim/vim/commit/e7a74d53754765f22ef8ce71c915bb669d5f7f3f
Author: Bram Moolenaar <Bram@vim.org>
Date: Sat Mar 19 11:10:15 2022 +0000
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 https://github.com/vim/vim/issues/9970)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sat, 19 Mar 2022 12:15:04 +0100 |
parents | c1d1639b52dd |
children | bef82285dda0 |
comparison
equal
deleted
inserted
replaced
28132:a4c48c2beb9f | 28133:373f1afadfa3 |
---|---|
1461 long fold_count; | 1461 long fold_count; |
1462 #endif | 1462 #endif |
1463 #ifdef FEAT_SYN_HL | 1463 #ifdef FEAT_SYN_HL |
1464 // remember what happened to the previous line, to know if | 1464 // remember what happened to the previous line, to know if |
1465 // check_visual_highlight() can be used | 1465 // check_visual_highlight() can be used |
1466 #define DID_NONE 1 // didn't update a line | 1466 # define DID_NONE 1 // didn't update a line |
1467 #define DID_LINE 2 // updated a normal line | 1467 # define DID_LINE 2 // updated a normal line |
1468 #define DID_FOLD 3 // updated a folded line | 1468 # define DID_FOLD 3 // updated a folded line |
1469 int did_update = DID_NONE; | 1469 int did_update = DID_NONE; |
1470 linenr_T syntax_last_parsed = 0; // last parsed text line | 1470 linenr_T syntax_last_parsed = 0; // last parsed text line |
1471 // remember the current w_last_cursorline, it changes when drawing the new | |
1472 // cursor line | |
1473 linenr_T last_cursorline = wp->w_last_cursorline; | |
1471 #endif | 1474 #endif |
1472 linenr_T mod_top = 0; | 1475 linenr_T mod_top = 0; |
1473 linenr_T mod_bot = 0; | 1476 linenr_T mod_bot = 0; |
1474 #if defined(FEAT_SYN_HL) || defined(FEAT_SEARCH_EXTRA) | 1477 #if defined(FEAT_SYN_HL) || defined(FEAT_SEARCH_EXTRA) |
1475 int save_got_int; | 1478 int save_got_int; |
2242 && buf->b_mod_xlines != 0) | 2245 && buf->b_mod_xlines != 0) |
2243 #endif | 2246 #endif |
2244 )))) | 2247 )))) |
2245 #ifdef FEAT_SYN_HL | 2248 #ifdef FEAT_SYN_HL |
2246 || (wp->w_p_cul && (lnum == wp->w_cursor.lnum | 2249 || (wp->w_p_cul && (lnum == wp->w_cursor.lnum |
2247 || lnum == wp->w_last_cursorline)) | 2250 || lnum == last_cursorline)) |
2248 #endif | 2251 #endif |
2249 ) | 2252 ) |
2250 { | 2253 { |
2251 #ifdef FEAT_SEARCH_EXTRA | 2254 #ifdef FEAT_SEARCH_EXTRA |
2252 if (lnum == mod_top) | 2255 if (lnum == mod_top) |
3025 | 3028 |
3026 return ret; | 3029 return ret; |
3027 } | 3030 } |
3028 #endif | 3031 #endif |
3029 | 3032 |
3033 #if defined(FEAT_SYN_HL) || defined(PROTO) | |
3034 /* | |
3035 * Check if the cursor moved and 'cursorline' is set. Mark for a VALID redraw | |
3036 * if needed. | |
3037 */ | |
3038 void | |
3039 check_redraw_cursorline(void) | |
3040 { | |
3041 // When 'cursorlineopt' is "screenline" need to redraw always. | |
3042 if (curwin->w_p_cul | |
3043 && (curwin->w_last_cursorline != curwin->w_cursor.lnum | |
3044 || (curwin->w_p_culopt_flags & CULOPT_SCRLINE)) | |
3045 && !char_avail()) | |
3046 redraw_later(VALID); | |
3047 } | |
3048 #endif | |
3049 | |
3030 /* | 3050 /* |
3031 * Invoked after an asynchronous callback is called. | 3051 * Invoked after an asynchronous callback is called. |
3032 * If an echo command was used the cursor needs to be put back where | 3052 * If an echo command was used the cursor needs to be put back where |
3033 * it belongs. If highlighting was changed a redraw is needed. | 3053 * it belongs. If highlighting was changed a redraw is needed. |
3034 * If "call_update_screen" is FALSE don't call update_screen() when at the | 3054 * If "call_update_screen" is FALSE don't call update_screen() when at the |
3069 redrawcmdline_ex(FALSE); | 3089 redrawcmdline_ex(FALSE); |
3070 } | 3090 } |
3071 } | 3091 } |
3072 else if (State & (NORMAL | INSERT | TERMINAL)) | 3092 else if (State & (NORMAL | INSERT | TERMINAL)) |
3073 { | 3093 { |
3094 #ifdef FEAT_SYN_HL | |
3095 // might need to update for 'cursorline' | |
3096 check_redraw_cursorline(); | |
3097 #endif | |
3074 // keep the command line if possible | 3098 // keep the command line if possible |
3075 update_screen(VALID_NO_UPDATE); | 3099 update_screen(VALID_NO_UPDATE); |
3076 setcursor(); | 3100 setcursor(); |
3077 | 3101 |
3078 if (msg_scrolled == 0) | 3102 if (msg_scrolled == 0) |