fix(tabpage): check if ROWS_AVAIL changed for resize (#19620)

N/A patches for version.c:

vim-patch:9.0.0135: comment about tabpage line above the wrong code

Problem:    Comment about tabpage line above the wrong code.
Solution:   Move the comment. (closes vim/vim#10836)
0b0ccbbfb0
This commit is contained in:
zeertzjq 2022-08-02 20:48:41 +08:00 committed by GitHub
parent 8ce7e7409f
commit def0ced4c7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 55 additions and 16 deletions

View File

@ -947,16 +947,15 @@ struct diffblock_S {
typedef struct tabpage_S tabpage_T;
struct tabpage_S {
handle_T handle;
tabpage_T *tp_next; ///< next tabpage or NULL
frame_T *tp_topframe; ///< topframe for the windows
win_T *tp_curwin; ///< current window in this Tab page
win_T *tp_prevwin; ///< previous window in this Tab page
win_T *tp_firstwin; ///< first window in this Tab page
win_T *tp_lastwin; ///< last window in this Tab page
long tp_old_Rows; ///< Rows when Tab page was left
long tp_old_Columns; ///< Columns when Tab page was left
long tp_ch_used; ///< value of 'cmdheight' when frame size
///< was set
tabpage_T *tp_next; ///< next tabpage or NULL
frame_T *tp_topframe; ///< topframe for the windows
win_T *tp_curwin; ///< current window in this Tab page
win_T *tp_prevwin; ///< previous window in this Tab page
win_T *tp_firstwin; ///< first window in this Tab page
win_T *tp_lastwin; ///< last window in this Tab page
long tp_old_Rows_avail; ///< ROWS_AVAIL when Tab page was left
long tp_old_Columns; ///< Columns when Tab page was left
long tp_ch_used; ///< value of 'cmdheight' when frame size was set
diff_T *tp_first_diff;
buf_T *(tp_diffbuf[DB_COUNT]);

View File

@ -4293,7 +4293,7 @@ static int leave_tabpage(buf_T *new_curbuf, bool trigger_leave_autocmds)
tp->tp_prevwin = prevwin;
tp->tp_firstwin = firstwin;
tp->tp_lastwin = lastwin;
tp->tp_old_Rows = Rows;
tp->tp_old_Rows_avail = ROWS_AVAIL;
tp->tp_old_Columns = Columns;
firstwin = NULL;
lastwin = NULL;
@ -4333,10 +4333,7 @@ static void enter_tabpage(tabpage_T *tp, buf_T *old_curbuf, bool trigger_enter_a
const int row = win_comp_pos(); // recompute w_winrow for all windows
diff_need_scrollbind = true;
// The tabpage line may have appeared or disappeared, may need to resize
// 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.
// 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;
}
@ -4349,7 +4346,9 @@ static void enter_tabpage(tabpage_T *tp, buf_T *old_curbuf, bool trigger_enter_a
clear_cmdline = true;
}
if (curtab->tp_old_Rows != Rows || (old_off != firstwin->w_winrow)) {
// The tabpage line may have appeared or disappeared, may need to resize the frames for that.
// When the Vim window was resized or ROWS_AVAIL changed need to update frame sizes too.
if (curtab->tp_old_Rows_avail != ROWS_AVAIL || (old_off != firstwin->w_winrow)) {
win_new_screen_rows();
}
if (curtab->tp_old_Columns != Columns && starting == 0) {

View File

@ -1,4 +1,5 @@
local helpers = require('test.functional.helpers')(after_each)
local Screen = require('test.functional.ui.screen')
local clear = helpers.clear
local command = helpers.command
@ -53,6 +54,46 @@ describe('tabpage', function()
neq(999, eval('g:win_closed'))
end)
it('switching tabpage after setting laststatus=3 #19591', function()
local screen = Screen.new(40, 8)
screen:set_default_attr_ids({
[0] = {bold = true, foreground = Screen.colors.Blue},
[1] = {bold = true, reverse = true}, -- StatusLine
[2] = {reverse = true}, -- StatusLineNC, TabLineFill
[3] = {bold = true}, -- TabLineSel
[4] = {background = Screen.colors.LightGrey, underline = true}, -- TabLine
[5] = {bold = true, foreground = Screen.colors.Magenta},
})
screen:attach()
command('tabnew')
command('tabprev')
command('set laststatus=3')
command('tabnext')
feed('<C-G>')
screen:expect([[
{4: [No Name] }{3: [No Name] }{2: }{4:X}|
^ |
{0:~ }|
{0:~ }|
{0:~ }|
{0:~ }|
{1:[No Name] }|
"[No Name]" --No lines in buffer-- |
]])
command('vnew')
screen:expect([[
{4: [No Name] }{3: }{5:2}{3: [No Name] }{2: }{4:X}|
^ |
{0:~ }{0:~ }|
{0:~ }{0:~ }|
{0:~ }{0:~ }|
{0:~ }{0:~ }|
{1:[No Name] }|
"[No Name]" --No lines in buffer-- |
]])
end)
it(":tabmove handles modifiers and addr", function()
command('tabnew | tabnew | tabnew')
eq(4, funcs.nvim_tabpage_get_number(0))