comparison src/move.c @ 31115:b7834109fefe v9.0.0892

patch 9.0.0892: may redraw when not needed Commit: https://github.com/vim/vim/commit/f32fb93e431e4db95a8663d86dfeb6bffa5896f6 Author: Bram Moolenaar <Bram@vim.org> Date: Thu Nov 17 11:34:38 2022 +0000 patch 9.0.0892: may redraw when not needed Problem: May redraw when not needed, causing slow scrolling. Solution: Do not redraw when w_skipcol doesn't change. When w_skipcol changes only redraw from the top. (issue #11559)
author Bram Moolenaar <Bram@vim.org>
date Thu, 17 Nov 2022 12:45:05 +0100
parents 1819fe895aea
children a5bf86083558
comparison
equal deleted inserted replaced
31114:d1c864c76e5c 31115:b7834109fefe
198 else if (wp->w_p_cul && (wp->w_p_culopt_flags & CULOPT_SCRLINE)) 198 else if (wp->w_p_cul && (wp->w_p_culopt_flags & CULOPT_SCRLINE))
199 redraw_win_later(wp, UPD_VALID); 199 redraw_win_later(wp, UPD_VALID);
200 } 200 }
201 } 201 }
202 #endif 202 #endif
203
204 /*
205 * Set curwin->s_skipcol to zero and redraw later if needed.
206 */
207 static void
208 reset_skipcol(void)
209 {
210 if (curwin->w_skipcol != 0)
211 {
212 curwin->w_skipcol = 0;
213
214 // Should use the least expensive way that displays all that changed.
215 // UPD_NOT_VALID is too expensive, UPD_REDRAW_TOP does not redraw
216 // enough when the top line gets another screen line.
217 redraw_later(UPD_SOME_VALID);
218 }
219 }
203 220
204 /* 221 /*
205 * Update curwin->w_topline and redraw if necessary. 222 * Update curwin->w_topline and redraw if necessary.
206 * Used to update the screen before printing a message. 223 * Used to update the screen before printing a message.
207 */ 224 */
456 || curwin->w_topfill != old_topfill 473 || curwin->w_topfill != old_topfill
457 #endif 474 #endif
458 ) 475 )
459 { 476 {
460 dollar_vcol = -1; 477 dollar_vcol = -1;
461 if (curwin->w_skipcol != 0) 478 redraw_later(UPD_VALID);
462 { 479 reset_skipcol();
463 curwin->w_skipcol = 0; 480
464 redraw_later(UPD_NOT_VALID);
465 }
466 else
467 redraw_later(UPD_VALID);
468 // May need to set w_skipcol when cursor in w_topline. 481 // May need to set w_skipcol when cursor in w_topline.
469 if (curwin->w_cursor.lnum == curwin->w_topline) 482 if (curwin->w_cursor.lnum == curwin->w_topline)
470 validate_cursor(); 483 validate_cursor();
471 } 484 }
472 485
1317 win_del_lines(curwin, 0, -extra, FALSE, FALSE, 0); 1330 win_del_lines(curwin, 0, -extra, FALSE, FALSE, 0);
1318 } 1331 }
1319 else if (!curwin->w_p_sms) 1332 else if (!curwin->w_p_sms)
1320 curwin->w_skipcol = 0; 1333 curwin->w_skipcol = 0;
1321 if (prev_skipcol != curwin->w_skipcol) 1334 if (prev_skipcol != curwin->w_skipcol)
1322 redraw_later(UPD_NOT_VALID); 1335 redraw_later(UPD_SOME_VALID);
1323 1336
1324 #ifdef FEAT_SYN_HL 1337 #ifdef FEAT_SYN_HL
1325 redraw_for_cursorcolumn(curwin); 1338 redraw_for_cursorcolumn(curwin);
1326 #endif 1339 #endif
1327 #if defined(FEAT_PROP_POPUP) && defined(FEAT_TERMINAL) 1340 #if defined(FEAT_PROP_POPUP) && defined(FEAT_TERMINAL)
1847 1860
1848 validate_cheight(); 1861 validate_cheight();
1849 if (curwin->w_cline_height == curwin->w_height) 1862 if (curwin->w_cline_height == curwin->w_height)
1850 { 1863 {
1851 // the line just fits in the window, don't scroll 1864 // the line just fits in the window, don't scroll
1852 if (curwin->w_skipcol != 0) 1865 reset_skipcol();
1853 {
1854 curwin->w_skipcol = 0;
1855 redraw_later(UPD_NOT_VALID);
1856 }
1857 return; 1866 return;
1858 } 1867 }
1859 1868
1860 validate_virtcol(); 1869 validate_virtcol();
1861 while (curwin->w_skipcol > 0 1870 while (curwin->w_skipcol > 0
2300 } 2309 }
2301 check_topfill(curwin, FALSE); 2310 check_topfill(curwin, FALSE);
2302 #endif 2311 #endif
2303 // TODO: if the line doesn't fit may optimize w_skipcol 2312 // TODO: if the line doesn't fit may optimize w_skipcol
2304 if (curwin->w_topline == curwin->w_cursor.lnum) 2313 if (curwin->w_topline == curwin->w_cursor.lnum)
2305 { 2314 reset_skipcol();
2306 curwin->w_skipcol = 0;
2307 redraw_later(UPD_NOT_VALID);
2308 }
2309 if (curwin->w_topline != old_topline 2315 if (curwin->w_topline != old_topline
2310 || curwin->w_skipcol != old_skipcol 2316 || curwin->w_skipcol != old_skipcol
2311 #ifdef FEAT_DIFF 2317 #ifdef FEAT_DIFF
2312 || curwin->w_topfill != old_topfill 2318 || curwin->w_topfill != old_topfill
2313 #endif 2319 #endif
2735 { 2741 {
2736 // 'smoothscroll is active 2742 // 'smoothscroll is active
2737 if (curwin->w_cline_height == curwin->w_height) 2743 if (curwin->w_cline_height == curwin->w_height)
2738 { 2744 {
2739 // The cursor line just fits in the window, don't scroll. 2745 // The cursor line just fits in the window, don't scroll.
2740 curwin->w_skipcol = 0; 2746 reset_skipcol();
2741 return; 2747 return;
2742 } 2748 }
2743 // TODO: If the cursor line doesn't fit in the window then only adjust 2749 // TODO: If the cursor line doesn't fit in the window then only adjust
2744 // w_skipcol. 2750 // w_skipcol.
2745 } 2751 }