Mercurial > vim
diff src/window.c @ 30624:f2f35161d75a v9.0.0647
patch 9.0.0647: the 'splitscroll' option is not a good name
Commit: https://github.com/vim/vim/commit/13ece2ae1d09009d3fb8acf858c288e7848ecdac
Author: Luuk van Baal <luukvbaal@gmail.com>
Date: Mon Oct 3 15:28:08 2022 +0100
patch 9.0.0647: the 'splitscroll' option is not a good name
Problem: The 'splitscroll' option is not a good name.
Solution: Rename 'splitscroll' to 'splitkeep' and make it a string option,
also supporting "topline". (Luuk van Baal, closes #11258)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Mon, 03 Oct 2022 16:30:04 +0200 |
parents | 66de6909e102 |
children | 101f08b49ed3 |
line wrap: on
line diff
--- a/src/window.c +++ b/src/window.c @@ -1325,7 +1325,7 @@ win_split_ins( win_equal(wp, TRUE, (flags & WSP_VERT) ? (dir == 'v' ? 'b' : 'h') : dir == 'h' ? 'b' : 'v'); - else if (!p_spsc && wp != aucmd_win) + else if (*p_spk != 'c' && wp != aucmd_win) win_fix_scroll(FALSE); // Don't change the window height/width to 'winheight' / 'winwidth' if a @@ -1411,7 +1411,7 @@ win_init(win_T *newp, win_T *oldp, int f newp->w_prevdir = (oldp->w_prevdir == NULL) ? NULL : vim_strsave(oldp->w_prevdir); - if (!p_spsc) + if (*p_spk != 'c') { newp->w_botline = oldp->w_botline; newp->w_prev_height = oldp->w_height - WINBAR_HEIGHT(oldp); @@ -1925,7 +1925,7 @@ win_equal( win_equal_rec(next_curwin == NULL ? curwin : next_curwin, current, topframe, dir, 0, tabline_height(), (int)Columns, topframe->fr_height); - if (!p_spsc && next_curwin != aucmd_win) + if (*p_spk != 'c' && next_curwin != aucmd_win) win_fix_scroll(TRUE); } @@ -2733,7 +2733,7 @@ win_close(win_T *win, int free_buf) else { win_comp_pos(); - if (!p_spsc) + if (*p_spk != 'c') win_fix_scroll(FALSE); } if (close_curwin) @@ -4931,7 +4931,7 @@ win_enter_ext(win_T *wp, int flags) // Might need to scroll the old window before switching, e.g., when the // cursor was moved. - if (p_spsc) + if (*p_spk == 'c') update_topline(); // may have to copy the buffer options when 'cpo' contains 'S' @@ -4947,7 +4947,7 @@ win_enter_ext(win_T *wp, int flags) check_cursor(); if (!virtual_active()) curwin->w_cursor.coladd = 0; - if (p_spsc) // assume cursor position needs updating. + if (*p_spk == 'c') // assume cursor position needs updating changed_line_abv_curs(); else win_fix_cursor(TRUE); @@ -5068,7 +5068,7 @@ static int last_win_id = LOWEST_WIN_ID - * FALSE. */ static win_T * -win_alloc(win_T *after UNUSED, int hidden UNUSED) +win_alloc(win_T *after, int hidden) { win_T *new_wp; @@ -5480,7 +5480,7 @@ shell_new_rows(void) compute_cmdrow(); curtab->tp_ch_used = p_ch; - if (!p_spsc && !skip_win_fix_scroll) + if (*p_spk != 'c' && !skip_win_fix_scroll) win_fix_scroll(TRUE); #if 0 @@ -5687,7 +5687,7 @@ win_setheight_win(int height, win_T *win msg_row = row; msg_col = 0; - if (!p_spsc) + if (*p_spk != 'c') win_fix_scroll(TRUE); redraw_all_later(UPD_NOT_VALID); @@ -6218,7 +6218,7 @@ win_drag_status_line(win_T *dragwin, int p_ch = MAX(Rows - cmdline_row, 1); curtab->tp_ch_used = p_ch; - if (!p_spsc) + if (*p_spk != 'c') win_fix_scroll(TRUE); redraw_all_later(UPD_SOME_VALID); @@ -6348,7 +6348,7 @@ set_fraction(win_T *wp) } /* - * Handle scroll position for 'nosplitscroll'. Replaces scroll_to_fraction() + * Handle scroll position for 'splitkeep'. Replaces scroll_to_fraction() * call from win_new_height(). Instead we iterate over all windows in a * tabpage and calculate the new scroll position. * TODO: Ensure this also works with wrapped lines. @@ -6362,14 +6362,14 @@ win_fix_scroll(int resize) win_T *wp; linenr_T lnum; - skip_update_topline = TRUE; // avoid scrolling in curs_columns() + skip_update_topline = TRUE; FOR_ALL_WINDOWS(wp) { // Skip when window height has not changed. if (wp->w_height != wp->w_prev_height) { // If window has moved update botline to keep the same screenlines. - if (wp->w_winrow != wp->w_prev_winrow) + if (*p_spk == 's' && wp->w_winrow != wp->w_prev_winrow) { lnum = wp->w_cursor.lnum; diff = (wp->w_winrow - wp->w_prev_winrow) @@ -6403,7 +6403,7 @@ win_fix_scroll(int resize) } /* - * Make sure the cursor position is valid for 'nosplitscroll'. + * Make sure the cursor position is valid for 'splitkeep'. * If it is not, put the cursor position in the jumplist and move it. * If we are not in normal mode, scroll to make valid instead. */ @@ -6413,9 +6413,9 @@ win_fix_cursor(int normal) long so = get_scrolloff_value(); win_T *wp = curwin; linenr_T nlnum = 0; - linenr_T lnum = wp->w_cursor.lnum; - linenr_T bot; - linenr_T top; + linenr_T lnum = wp->w_cursor.lnum; + linenr_T bot; + linenr_T top; if (wp->w_buffer->b_ml.ml_line_count < wp->w_height) return; @@ -6429,25 +6429,23 @@ win_fix_cursor(int normal) top = cursor_down_inner(wp, so); wp->w_cursor.lnum = wp->w_botline - 1; bot = cursor_up_inner(wp, so); + wp->w_cursor.lnum = lnum; // Check if cursor position is above or below valid cursor range. if (lnum > bot && (wp->w_botline - wp->w_buffer->b_ml.ml_line_count) != 1) nlnum = bot; else if (lnum < top && wp->w_topline != 1) nlnum = (so == wp->w_height / 2) ? bot : top; - wp->w_cursor.lnum = lnum; - if (nlnum) // Cursor is invalid for current scroll position. { if (normal) // Save to jumplist and set cursor to avoid scrolling. { setmark('\''); wp->w_cursor.lnum = nlnum; - curs_columns(TRUE); // validate w_wrow } else // Scroll instead when not in normal mode. { - wp->w_fraction = 0.5 * FRACTION_MULT; + wp->w_fraction = (nlnum == bot) ? FRACTION_MULT : 0; scroll_to_fraction(wp, wp->w_prev_height); validate_botline_win(curwin); } @@ -6474,7 +6472,7 @@ win_new_height(win_T *wp, int height) if (wp->w_height > 0) { - if (wp == curwin && p_spsc) + if (wp == curwin && *p_spk == 'c') // w_wrow needs to be valid. When setting 'laststatus' this may // call win_new_height() recursively. validate_cursor(); @@ -6490,7 +6488,7 @@ win_new_height(win_T *wp, int height) // There is no point in adjusting the scroll position when exiting. Some // values might be invalid. - if (!exiting && p_spsc) + if (!exiting && *p_spk == 'c') scroll_to_fraction(wp, prev_height); } @@ -6604,7 +6602,7 @@ scroll_to_fraction(win_T *wp, int prev_h if (wp == curwin) { - if (p_spsc && get_scrolloff_value()) + if (get_scrolloff_value()) update_topline(); curs_columns(FALSE); // validate w_wrow } @@ -6627,15 +6625,13 @@ win_new_width(win_T *wp, int width) wp->w_width = width < 0 ? 0 : width; wp->w_lines_valid = 0; changed_line_abv_curs_win(wp); - // Handled in win_fix_scroll() - if (p_spsc) - { - invalidate_botline_win(wp); - if (wp == curwin) - { - update_topline(); - curs_columns(TRUE); // validate w_wrow - } + invalidate_botline_win(wp); + if (wp == curwin) + { + skip_update_topline = (*p_spk != 'c'); + update_topline(); + curs_columns(TRUE); // validate w_wrow + skip_update_topline = FALSE; } redraw_win_later(wp, UPD_NOT_VALID); wp->w_redr_status = TRUE;