Merge #28522 handle ui_attach side effects

This commit is contained in:
Justin M. Keyes 2024-04-27 06:37:40 -07:00 committed by GitHub
commit 158e329725
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 29 additions and 12 deletions

View File

@ -194,15 +194,6 @@ void ui_refresh(void)
abort();
}
if (!ui_active()) {
return;
}
if (updating_screen) {
ui_schedule_refresh();
return;
}
int width = INT_MAX;
int height = INT_MAX;
bool ext_widgets[kUIExtCount];
@ -227,18 +218,29 @@ void ui_refresh(void)
if (i < kUIGlobalCount) {
ext_widgets[i] |= ui_cb_ext[i];
}
// Set 'cmdheight' to zero when ext_messages becomes active.
// Set 'cmdheight' to zero when ext_messages becomes active for all tabpages.
if (i == kUIMessages && !ui_ext[i] && ext_widgets[i]) {
set_option_value(kOptCmdheight, NUMBER_OPTVAL(0), 0);
command_height();
FOR_ALL_TABS(tp) {
tp->tp_ch_used = 0;
}
}
ui_ext[i] = ext_widgets[i];
if (i < kUIGlobalCount) {
ui_call_option_set(cstr_as_string(ui_ext_names[i]),
BOOLEAN_OBJ(ext_widgets[i]));
ui_call_option_set(cstr_as_string(ui_ext_names[i]), BOOLEAN_OBJ(ext_widgets[i]));
}
}
if (!ui_active()) {
return;
}
if (updating_screen) {
ui_schedule_refresh();
return;
}
ui_default_colors_set();
int save_p_lz = p_lz;

View File

@ -155,6 +155,21 @@ describe('vim.ui_attach', function()
},
}, actual, vim.inspect(actual))
end)
it('ui_refresh() works without remote UI', function()
screen:detach()
exec_lua('vim.ui_attach(ns, { ext_messages = true }, on_event)')
n.api.nvim_set_option_value('cmdheight', 1, {})
screen:attach()
eq(1, n.api.nvim_get_option_value('cmdheight', {}))
end)
it("ui_refresh() sets 'cmdheight' for all open tabpages with ext_messages", function()
exec_lua('vim.cmd.tabnew()')
exec_lua('vim.ui_attach(ns, { ext_messages = true }, on_event)')
exec_lua('vim.cmd.tabnext()')
eq(0, n.api.nvim_get_option_value('cmdheight', {}))
end)
end)
describe('vim.ui_attach', function()