comparison src/window.c @ 30285:9edb1a8161ac v9.0.0478

patch 9.0.0478: test for 'splitscroll' takes too much time Commit: https://github.com/vim/vim/commit/594f9e09cd68e6277b8aa08094405bc642c5792a Author: Luuk van Baal <luukvbaal@gmail.com> Date: Fri Sep 16 12:52:58 2022 +0100 patch 9.0.0478: test for 'splitscroll' takes too much time Problem: Test for 'splitscroll' takes too much time. Solution: Only test some of the combinations. (Luuk van Baal, closes https://github.com/vim/vim/issues/11139)
author Bram Moolenaar <Bram@vim.org>
date Fri, 16 Sep 2022 14:00:05 +0200
parents be97adfeac3a
children b9d07900b0b8
comparison
equal deleted inserted replaced
30284:5ba1ec8cf49f 30285:9edb1a8161ac
6401 * If we are not in normal mode, scroll to make valid instead. 6401 * If we are not in normal mode, scroll to make valid instead.
6402 */ 6402 */
6403 static void 6403 static void
6404 win_fix_cursor(int normal) 6404 win_fix_cursor(int normal)
6405 { 6405 {
6406 int top = FALSE;
6407 win_T *wp = curwin; 6406 win_T *wp = curwin;
6408 long so = get_scrolloff_value(); 6407 long so = get_scrolloff_value();
6409 linenr_T nlnum = 0; 6408 linenr_T nlnum = 0;
6410 6409
6411 if (wp->w_buffer->b_ml.ml_line_count < wp->w_height) 6410 if (wp->w_buffer->b_ml.ml_line_count < wp->w_height)
6416 #endif 6415 #endif
6417 6416
6418 so = MIN(wp->w_height / 2, so); 6417 so = MIN(wp->w_height / 2, so);
6419 // Check if cursor position is above topline or below botline. 6418 // Check if cursor position is above topline or below botline.
6420 if (wp->w_cursor.lnum < (wp->w_topline + so) && wp->w_topline != 1) 6419 if (wp->w_cursor.lnum < (wp->w_topline + so) && wp->w_topline != 1)
6421 top = nlnum = MIN(wp->w_topline + so, wp->w_buffer->b_ml.ml_line_count); 6420 nlnum = MIN(wp->w_topline + so, wp->w_buffer->b_ml.ml_line_count);
6422 else if (wp->w_cursor.lnum > (wp->w_botline - so - 1) 6421 else if (wp->w_cursor.lnum > (wp->w_botline - so - 1)
6423 && (wp->w_botline - wp->w_buffer->b_ml.ml_line_count) != 1) 6422 && (wp->w_botline - wp->w_buffer->b_ml.ml_line_count) != 1)
6424 nlnum = MAX(wp->w_botline - so - 1, 1); 6423 nlnum = MAX(wp->w_botline - so - 1, 1);
6425 // If cursor was invalid scroll or change cursor. 6424 // If cursor was invalid scroll or change cursor.
6426 if (nlnum) 6425 if (nlnum)
6434 wp->w_cursor.lnum = nlnum; // change to avoid scrolling 6433 wp->w_cursor.lnum = nlnum; // change to avoid scrolling
6435 curs_columns(TRUE); // validate w_wrow 6434 curs_columns(TRUE); // validate w_wrow
6436 } 6435 }
6437 else 6436 else
6438 { // Ensure cursor stays visible if we are not in normal mode. 6437 { // Ensure cursor stays visible if we are not in normal mode.
6439 wp->w_fraction = top ? 0 : FRACTION_MULT; 6438 wp->w_fraction = 0.5 * FRACTION_MULT;
6439 // Make sure cursor is closer to topline than botline.
6440 if (so == wp->w_height / 2
6441 && nlnum - wp->w_topline > wp->w_botline - 1 - nlnum)
6442 wp->w_fraction++;
6440 scroll_to_fraction(wp, wp->w_prev_height); 6443 scroll_to_fraction(wp, wp->w_prev_height);
6441 } 6444 }
6442 } 6445 }
6443 } 6446 }
6444 6447