diff options
Diffstat (limited to 'src/nvim/window.c')
-rw-r--r-- | src/nvim/window.c | 48 |
1 files changed, 38 insertions, 10 deletions
diff --git a/src/nvim/window.c b/src/nvim/window.c index 9d8cd21dba..6bc082ffb2 100644 --- a/src/nvim/window.c +++ b/src/nvim/window.c @@ -2295,8 +2295,7 @@ int win_close(win_T *win, bool free_buf) EMSG(_("E813: Cannot close autocmd window")); return FAIL; } - if ((firstwin == aucmd_win || lastwin_nofloating() == aucmd_win) - && one_window()) { + if ((firstwin == aucmd_win || lastwin == aucmd_win) && one_window()) { EMSG(_("E814: Cannot close window, only autocmd window would remain")); return FAIL; } @@ -3413,16 +3412,18 @@ int win_alloc_first(void) return OK; } -/* - * Init "aucmd_win". This can only be done after the first - * window is fully initialized, thus it can't be in win_alloc_first(). - */ +// Init `aucmd_win`. This can only be done after the first window +// is fully initialized, thus it can't be in win_alloc_first(). void win_alloc_aucmd_win(void) { - aucmd_win = win_alloc(NULL, TRUE); - win_init_some(aucmd_win, curwin); + Error err = ERROR_INIT; + FloatConfig fconfig = FLOAT_CONFIG_INIT; + fconfig.width = Columns; + fconfig.height = 5; + fconfig.focusable = false; + aucmd_win = win_new_float(NULL, fconfig, &err); + aucmd_win->w_buffer->b_nwindows--; RESET_BINDING(aucmd_win); - new_frame(aucmd_win); } /* @@ -3793,6 +3794,9 @@ static void enter_tabpage(tabpage_T *tp, buf_T *old_curbuf, int trigger_enter_au * the frames for that. When the Vim window was resized need to update * frame sizes too. Use the stored value of p_ch, so that it can be * different for each tab page. */ + if (p_ch != curtab->tp_ch_used) { + clear_cmdline = true; + } p_ch = curtab->tp_ch_used; if (curtab->tp_old_Rows != Rows || (old_off != firstwin->w_winrow )) @@ -3847,7 +3851,7 @@ static void tabpage_check_windows(tabpage_T *old_curtab) */ void goto_tabpage(int n) { - tabpage_T *tp; + tabpage_T *tp = NULL; // shut up compiler tabpage_T *ttp; int i; @@ -5959,16 +5963,40 @@ void check_lnums(int do_curwin) { FOR_ALL_TAB_WINDOWS(tp, wp) { if ((do_curwin || wp != curwin) && wp->w_buffer == curbuf) { + // save the original cursor position and topline + wp->w_save_cursor.w_cursor_save = wp->w_cursor; + wp->w_save_cursor.w_topline_save = wp->w_topline; + if (wp->w_cursor.lnum > curbuf->b_ml.ml_line_count) { wp->w_cursor.lnum = curbuf->b_ml.ml_line_count; } if (wp->w_topline > curbuf->b_ml.ml_line_count) { wp->w_topline = curbuf->b_ml.ml_line_count; } + + // save the corrected cursor position and topline + wp->w_save_cursor.w_cursor_corr = wp->w_cursor; + wp->w_save_cursor.w_topline_corr = wp->w_topline; } } } +/// Reset cursor and topline to its stored values from check_lnums(). +/// check_lnums() must have been called first! +void reset_lnums(void) +{ + FOR_ALL_TAB_WINDOWS(tp, wp) { + if (wp->w_buffer == curbuf) { + // Restore the value if the autocommand didn't change it. + if (equalpos(wp->w_save_cursor.w_cursor_corr, wp->w_cursor)) { + wp->w_cursor = wp->w_save_cursor.w_cursor_save; + } + if (wp->w_save_cursor.w_topline_corr == wp->w_topline) { + wp->w_topline = wp->w_save_cursor.w_topline_save; + } + } + } +} /* * A snapshot of the window sizes, to restore them after closing the help |