diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/nvim/ex_session.c | 9 | ||||
-rw-r--r-- | src/nvim/mouse.c | 16 | ||||
-rw-r--r-- | src/nvim/testdir/test_mksession.vim | 24 | ||||
-rw-r--r-- | src/nvim/window.c | 39 |
4 files changed, 73 insertions, 15 deletions
diff --git a/src/nvim/ex_session.c b/src/nvim/ex_session.c index 7eef6707dd..dfdb8c1eac 100644 --- a/src/nvim/ex_session.c +++ b/src/nvim/ex_session.c @@ -598,9 +598,14 @@ static int makeopens(FILE *fd, char_u *dirnow) PUTLINE_FAIL("let s:shortmess_save = &shortmess"); } - // Now save the current files, current buffer first. - PUTLINE_FAIL("set shortmess=aoO"); + // set 'shortmess' for the following. Add the 'A' flag if it was there + PUTLINE_FAIL("if &shortmess =~ 'A'"); + PUTLINE_FAIL(" set shortmess=aoOA"); + PUTLINE_FAIL("else"); + PUTLINE_FAIL(" set shortmess=aoO"); + PUTLINE_FAIL("endif"); + // Now save the current files, current buffer first. // Put all buffers into the buffer list. // Do it very early to preserve buffer order after loading session (which // can be disrupted by prior `edit` or `tabedit` calls). diff --git a/src/nvim/mouse.c b/src/nvim/mouse.c index fe21279ef7..8736c73080 100644 --- a/src/nvim/mouse.c +++ b/src/nvim/mouse.c @@ -159,16 +159,16 @@ retnomove: fdc = win_fdccol_count(wp); dragwin = NULL; - if (row == -1 + wp->w_winbar_height) { - on_winbar = !!wp->w_winbar_height; + if (row == -1) { + on_winbar = wp->w_winbar_height != 0; return IN_OTHER_WIN | (on_winbar ? MOUSE_WINBAR : 0); } on_winbar = false; // winpos and height may change in win_enter()! - if (grid == DEFAULT_GRID_HANDLE && row >= wp->w_height) { + if (grid == DEFAULT_GRID_HANDLE && row + wp->w_winbar_height >= wp->w_height) { // In (or below) status line - on_status_line = row - wp->w_height + 1; + on_status_line = row + wp->w_winbar_height - wp->w_height + 1; dragwin = wp; } else { on_status_line = 0; @@ -273,6 +273,9 @@ retnomove: if (grid == 0) { row -= curwin->w_grid_alloc.comp_row + curwin->w_grid.row_offset; col -= curwin->w_grid_alloc.comp_col + curwin->w_grid.col_offset; + } else if (grid != DEFAULT_GRID_HANDLE) { + row -= curwin->w_grid.row_offset; + col -= curwin->w_grid.col_offset; } // When clicking beyond the end of the window, scroll the screen. @@ -406,9 +409,6 @@ bool mouse_comp_pos(win_T *win, int *rowp, int *colp, linenr_T *lnump) if (win->w_p_rl) { col = win->w_width_inner - 1 - col; } - if (win->w_winbar_height) { - row -= win->w_winbar_height; - } lnum = win->w_topline; @@ -509,7 +509,7 @@ win_T *mouse_find_win(int *gridp, int *rowp, int *colp) // exist. FOR_ALL_WINDOWS_IN_TAB(wp, curtab) { if (wp == fp->fr_win) { - *rowp -= wp->w_winrow_off - wp->w_winbar_height; + *rowp -= wp->w_winbar_height; return wp; } } diff --git a/src/nvim/testdir/test_mksession.vim b/src/nvim/testdir/test_mksession.vim index 5dbe2cd366..c55ba391a5 100644 --- a/src/nvim/testdir/test_mksession.vim +++ b/src/nvim/testdir/test_mksession.vim @@ -838,6 +838,30 @@ func Test_mksession_shortmess() set sessionoptions& endfunc +" Test that when Vim loading session has 'A' in 'shortmess' it does not +" complain about an existing swapfile. +func Test_mksession_shortmess_with_A() + edit Xtestfile + write + let fname = swapname('%') + " readblob() needs patch 8.2.2343 + " let cont = readblob(fname) + let cont = readfile(fname, 'B') + set sessionoptions-=options + mksession Xtestsession + bwipe! + + " Recreate the swap file to pretend the file is being edited + call writefile(cont, fname) + set shortmess+=A + source Xtestsession + + set shortmess& + set sessionoptions& + call delete('Xtestsession') + call delete(fname) +endfunc + " Test for mksession with 'compatible' option func Test_mksession_compatible() throw 'skipped: Nvim does not support "compatible" option' diff --git a/src/nvim/window.c b/src/nvim/window.c index 9c9b1fe176..4076bb2531 100644 --- a/src/nvim/window.c +++ b/src/nvim/window.c @@ -2033,6 +2033,37 @@ void win_move_after(win_T *win1, win_T *win2) win2->w_pos_changed = true; } +/// Compute maximum number of windows that can fit within "height" in frame "fr". +static int get_maximum_wincount(frame_T *fr, int height) +{ + if (fr->fr_layout != FR_COL) { + return (height / (p_wmh + STATUS_HEIGHT + frame2win(fr)->w_winbar_height)); + } else if (global_winbar_height()) { + // If winbar is globally enabled, no need to check each window for it. + return (height / (p_wmh + STATUS_HEIGHT + 1)); + } + + frame_T *frp; + int total_wincount = 0; + + // First, try to fit all child frames of "fr" into "height" + FOR_ALL_FRAMES(frp, fr->fr_child) { + win_T *wp = frame2win(frp); + + if (height < (p_wmh + STATUS_HEIGHT + wp->w_winbar_height)) { + break; + } + height -= p_wmh + STATUS_HEIGHT + wp->w_winbar_height; + total_wincount += 1; + } + + // If we still have enough room for more windows, just use the default winbar height (which is 0) + // in order to get the amount of windows that'd fit in the remaining space + total_wincount += height / (p_wmh + STATUS_HEIGHT); + + return total_wincount; +} + /// Make all windows the same height. ///'next_curwin' will soon be the current window, make sure it has enough rows. /// @@ -2232,7 +2263,7 @@ static void win_equal_rec(win_T *next_curwin, bool current, frame_T *topfr, int } else { extra_sep = 0; } - totwincount = (n + extra_sep) / (p_wmh + STATUS_HEIGHT + global_winbar_height()); + totwincount = get_maximum_wincount(topfr, n + extra_sep); has_next_curwin = frame_has_win(topfr, next_curwin); /* @@ -2266,8 +2297,7 @@ static void win_equal_rec(win_T *next_curwin, bool current, frame_T *topfr, int } } else { // These windows don't use up room. - totwincount -= (n + (fr->fr_next == NULL - ? extra_sep : 0)) / (p_wmh + STATUS_HEIGHT + global_winbar_height()); + totwincount -= get_maximum_wincount(fr, (n + (fr->fr_next == NULL ? extra_sep : 0))); } room -= new_size - n; if (room < 0) { @@ -2312,8 +2342,7 @@ static void win_equal_rec(win_T *next_curwin, bool current, frame_T *topfr, int } else { // Compute the maximum number of windows vert. in "fr". n = frame_minheight(fr, NOWIN); - wincount = (n + (fr->fr_next == NULL ? extra_sep : 0)) - / (p_wmh + STATUS_HEIGHT + global_winbar_height()); + wincount = get_maximum_wincount(fr, (n + (fr->fr_next == NULL ? extra_sep : 0))); m = frame_minheight(fr, next_curwin); if (has_next_curwin) { hnc = frame_has_win(fr, next_curwin); |