To: vim_dev@googlegroups.com Subject: Patch 8.1.1918 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.1.1918 Problem: Redrawing popups is inefficient. Solution: Fix the logic to compute what window lines to redraw. Make it work below the last line. Remove redrawing all windows. Files: src/popupwin.c *** ../vim-8.1.1917/src/popupwin.c 2019-08-24 14:46:26.204051454 +0200 --- src/popupwin.c 2019-08-24 15:25:44.372472937 +0200 *************** *** 1228,1235 **** || org_height != wp->w_height) { redraw_win_later(wp, NOT_VALID); - redraw_all_later(SOME_VALID); - status_redraw_all(); if (wp->w_popup_flags & POPF_ON_CMDLINE) clear_cmdline = TRUE; popup_mask_refresh = TRUE; --- 1228,1233 ---- *************** *** 2816,2822 **** win_T *wp; short *mask; int line, col; ! int redraw_all = FALSE; // Need to recompute when switching tabs. // Also recompute when the type is CLEAR or NOT_VALID, something basic --- 2814,2821 ---- win_T *wp; short *mask; int line, col; ! int redraw_all_popups = FALSE; ! int redrawing_all_win; // Need to recompute when switching tabs. // Also recompute when the type is CLEAR or NOT_VALID, something basic *************** *** 2824,2834 **** if (popup_mask_tab != curtab || type >= NOT_VALID) { popup_mask_refresh = TRUE; ! redraw_all = TRUE; } if (!popup_mask_refresh) { ! // Check if any buffer has changed. for (wp = first_popupwin; wp != NULL; wp = wp->w_next) if (wp->w_popup_last_changedtick != CHANGEDTICK(wp->w_buffer)) popup_mask_refresh = TRUE; --- 2823,2833 ---- if (popup_mask_tab != curtab || type >= NOT_VALID) { popup_mask_refresh = TRUE; ! redraw_all_popups = TRUE; } if (!popup_mask_refresh) { ! // Check if any popup window buffer has changed. for (wp = first_popupwin; wp != NULL; wp = wp->w_next) if (wp->w_popup_last_changedtick != CHANGEDTICK(wp->w_buffer)) popup_mask_refresh = TRUE; *************** *** 2844,2853 **** popup_mask_tab = curtab; popup_visible = FALSE; ! // If redrawing everything, just update "popup_mask". // If redrawing only what is needed, update "popup_mask_next" and then // compare with "popup_mask" to see what changed. ! if (type >= SOME_VALID) mask = popup_mask; else mask = popup_mask_next; --- 2843,2856 ---- popup_mask_tab = curtab; popup_visible = FALSE; ! // If redrawing all windows, just update "popup_mask". // If redrawing only what is needed, update "popup_mask_next" and then // compare with "popup_mask" to see what changed. ! redrawing_all_win = TRUE; ! FOR_ALL_WINDOWS(wp) ! if (wp->w_redr_type < SOME_VALID) ! redrawing_all_win = FALSE; ! if (redrawing_all_win) mask = popup_mask; else mask = popup_mask_next; *************** *** 2865,2871 **** popup_visible = TRUE; // Recompute the position if the text changed. ! if (redraw_all || wp->w_popup_last_changedtick != CHANGEDTICK(wp->w_buffer)) popup_adjust_position(wp); --- 2868,2874 ---- popup_visible = TRUE; // Recompute the position if the text changed. ! if (redraw_all_popups || wp->w_popup_last_changedtick != CHANGEDTICK(wp->w_buffer)) popup_adjust_position(wp); *************** *** 2930,2943 **** if (line_cp >= wp->w_height) // In (or below) status line wp->w_redr_status = TRUE; - // compute the position in the buffer line from the - // position on the screen - else if (mouse_comp_pos(wp, &line_cp, &col_cp, - &lnum, plines_cache)) - // past bottom - wp->w_redr_status = TRUE; else redrawWinline(wp, lnum); // This line is going to be redrawn, no need to // check until the right side of the window. --- 2933,2946 ---- if (line_cp >= wp->w_height) // In (or below) status line wp->w_redr_status = TRUE; else + { + // compute the position in the buffer line from + // the position in the window + mouse_comp_pos(wp, &line_cp, &col_cp, + &lnum, plines_cache); redrawWinline(wp, lnum); + } // This line is going to be redrawn, no need to // check until the right side of the window. *** ../vim-8.1.1917/src/version.c 2019-08-24 14:46:26.208051433 +0200 --- src/version.c 2019-08-24 15:21:39.429682036 +0200 *************** *** 763,764 **** --- 763,766 ---- { /* Add new patch number below this line */ + /**/ + 1918, /**/ -- Laughing helps. It's like jogging on the inside. /// Bram Moolenaar -- Bram@Moolenaar.net -- 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 ///