comparison src/popupwin.c @ 18027:56032a704448 v8.1.2009

patch 8.1.2009: cursorline highlighting not updated in popup window Commit: https://github.com/vim/vim/commit/3d2a3cbce873af861031a01e02694dcfae0c4582 Author: Bram Moolenaar <Bram@vim.org> Date: Sun Sep 8 17:12:01 2019 +0200 patch 8.1.2009: cursorline highlighting not updated in popup window Problem: Cursorline highlighting not updated in popup window. (Marko Mahni?) Solution: Check if the cursor position changed. (closes #4912)
author Bram Moolenaar <Bram@vim.org>
date Sun, 08 Sep 2019 17:15:03 +0200
parents 6006bb74bd52
children 364a9be6a21e
comparison
equal deleted inserted replaced
18026:fa5278b7c49e 18027:56032a704448
540 static void 540 static void
541 popup_show_curline(win_T *wp) 541 popup_show_curline(win_T *wp)
542 { 542 {
543 if (wp->w_cursor.lnum < wp->w_topline) 543 if (wp->w_cursor.lnum < wp->w_topline)
544 wp->w_topline = wp->w_cursor.lnum; 544 wp->w_topline = wp->w_cursor.lnum;
545 else if (wp->w_cursor.lnum >= wp->w_botline) 545 else if (wp->w_cursor.lnum >= wp->w_botline
546 && (curwin->w_valid & VALID_BOTLINE))
547 {
546 wp->w_topline = wp->w_cursor.lnum - wp->w_height + 1; 548 wp->w_topline = wp->w_cursor.lnum - wp->w_height + 1;
549 if (wp->w_topline < 1)
550 wp->w_topline = 1;
551 else if (wp->w_topline > wp->w_buffer->b_ml.ml_line_count)
552 wp->w_topline = wp->w_buffer->b_ml.ml_line_count;
553 }
547 554
548 // Don't use "firstline" now. 555 // Don't use "firstline" now.
549 wp->w_firstline = 0; 556 wp->w_firstline = 0;
550 } 557 }
551 558
591 wp->w_buffer, wp->w_cursor.lnum, SIGN_DEF_PRIO); 598 wp->w_buffer, wp->w_cursor.lnum, SIGN_DEF_PRIO);
592 redraw_win_later(wp, NOT_VALID); 599 redraw_win_later(wp, NOT_VALID);
593 } 600 }
594 else 601 else
595 sign_undefine_by_name(sign_name, FALSE); 602 sign_undefine_by_name(sign_name, FALSE);
603 wp->w_popup_last_curline = wp->w_cursor.lnum;
596 } 604 }
597 605
598 /* 606 /*
599 * Shared between popup_create() and f_popup_setoptions(). 607 * Shared between popup_create() and f_popup_setoptions().
600 */ 608 */
1057 wp->w_wincol = 0; 1065 wp->w_wincol = 0;
1058 wp->w_leftcol = 0; 1066 wp->w_leftcol = 0;
1059 wp->w_popup_leftoff = 0; 1067 wp->w_popup_leftoff = 0;
1060 wp->w_popup_rightoff = 0; 1068 wp->w_popup_rightoff = 0;
1061 1069
1070 // May need to update the "cursorline" highlighting, which may also change
1071 // "topline"
1072 if (wp->w_popup_last_curline != wp->w_cursor.lnum)
1073 popup_highlight_curline(wp);
1074
1062 // If no line was specified default to vertical centering. 1075 // If no line was specified default to vertical centering.
1063 if (wantline == 0) 1076 if (wantline == 0)
1064 center_vert = TRUE; 1077 center_vert = TRUE;
1065 1078
1066 if (wp->w_popup_prop_type > 0 && win_valid(wp->w_popup_prop_win)) 1079 if (wp->w_popup_prop_type > 0 && win_valid(wp->w_popup_prop_win))
1157 } 1170 }
1158 1171
1159 // start at the desired first line 1172 // start at the desired first line
1160 if (wp->w_firstline > 0) 1173 if (wp->w_firstline > 0)
1161 wp->w_topline = wp->w_firstline; 1174 wp->w_topline = wp->w_firstline;
1162 if (wp->w_topline > wp->w_buffer->b_ml.ml_line_count) 1175 if (wp->w_topline < 1)
1176 wp->w_topline = 1;
1177 else if (wp->w_topline > wp->w_buffer->b_ml.ml_line_count)
1163 wp->w_topline = wp->w_buffer->b_ml.ml_line_count; 1178 wp->w_topline = wp->w_buffer->b_ml.ml_line_count;
1164 1179
1165 // Compute width based on longest text line and the 'wrap' option. 1180 // Compute width based on longest text line and the 'wrap' option.
1166 // Use a minimum width of one, so that something shows when there is no 1181 // Use a minimum width of one, so that something shows when there is no
1167 // text. 1182 // text.
2996 3011
2997 /* 3012 /*
2998 * Return TRUE if popup_adjust_position() needs to be called for "wp". 3013 * Return TRUE if popup_adjust_position() needs to be called for "wp".
2999 * That is when the buffer in the popup was changed, or the popup is following 3014 * That is when the buffer in the popup was changed, or the popup is following
3000 * a textprop and the referenced buffer was changed. 3015 * a textprop and the referenced buffer was changed.
3016 * Or when the cursor line changed and "cursorline" is set.
3001 */ 3017 */
3002 static int 3018 static int
3003 popup_need_position_adjust(win_T *wp) 3019 popup_need_position_adjust(win_T *wp)
3004 { 3020 {
3005 if (wp->w_popup_last_changedtick != CHANGEDTICK(wp->w_buffer)) 3021 if (wp->w_popup_last_changedtick != CHANGEDTICK(wp->w_buffer))
3006 return TRUE; 3022 return TRUE;
3007 if (win_valid(wp->w_popup_prop_win)) 3023 if (win_valid(wp->w_popup_prop_win))
3008 return wp->w_popup_prop_changedtick 3024 return wp->w_popup_prop_changedtick
3009 != CHANGEDTICK(wp->w_popup_prop_win->w_buffer) 3025 != CHANGEDTICK(wp->w_popup_prop_win->w_buffer)
3010 || wp->w_popup_prop_topline != wp->w_popup_prop_win->w_topline; 3026 || wp->w_popup_prop_topline != wp->w_popup_prop_win->w_topline
3027 || ((wp->w_popup_flags & POPF_CURSORLINE)
3028 && wp->w_cursor.lnum != wp->w_popup_last_curline);
3011 return FALSE; 3029 return FALSE;
3012 } 3030 }
3013 3031
3014 /* 3032 /*
3015 * Update "popup_mask" if needed. 3033 * Update "popup_mask" if needed.