mirror of
https://github.com/neovim/neovim.git
synced 2025-09-27 13:38:34 +00:00
feat(ui): avoid setting 'cmdheight' with vim.ui_attach()
Problem: We allow setting 'cmdheight' to 0 with ext_messages enabled
since b72931e7
. Enabling ext_messages with vim.ui_attach()
implicitly sets 'cmdheight' to 0 for BWC. When non-zero
'cmdheight' is wanted, this behavior make it unnecessarily
hard to keep track of the user configured value.
Solution: Add set_cmdheight to vim.ui_attach() opts table that can be
set to false to avoid setting 'cmdheight' to 0.
This commit is contained in:
@@ -682,7 +682,7 @@ static int nlua_ui_attach(lua_State *lstate)
|
||||
return luaL_error(lstate, "invalid ns_id");
|
||||
}
|
||||
if (!lua_istable(lstate, 2)) {
|
||||
return luaL_error(lstate, "ext_widgets must be a table");
|
||||
return luaL_error(lstate, "opts must be a table");
|
||||
}
|
||||
if (!lua_isfunction(lstate, 3)) {
|
||||
return luaL_error(lstate, "callback must be a Lua function");
|
||||
@@ -699,13 +699,18 @@ static int nlua_ui_attach(lua_State *lstate)
|
||||
const char *s = lua_tolstring(lstate, -2, &len);
|
||||
bool val = lua_toboolean(lstate, -1);
|
||||
|
||||
for (size_t i = 0; i < kUIGlobalCount; i++) {
|
||||
if (strequal(s, ui_ext_names[i])) {
|
||||
if (val) {
|
||||
tbl_has_true_val = true;
|
||||
if (strequal(s, "set_cmdheight")) {
|
||||
ui_refresh_cmdheight = val;
|
||||
goto ok;
|
||||
} else {
|
||||
for (size_t i = 0; i < kUIGlobalCount; i++) {
|
||||
if (strequal(s, ui_ext_names[i])) {
|
||||
if (val) {
|
||||
tbl_has_true_val = true;
|
||||
}
|
||||
ext_widgets[i] = val;
|
||||
goto ok;
|
||||
}
|
||||
ext_widgets[i] = val;
|
||||
goto ok;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -715,11 +720,12 @@ ok:
|
||||
}
|
||||
|
||||
if (!tbl_has_true_val) {
|
||||
return luaL_error(lstate, "ext_widgets table must contain at least one 'true' value");
|
||||
return luaL_error(lstate, "opts table must contain at least one 'true' ext_widget");
|
||||
}
|
||||
|
||||
LuaRef ui_event_cb = nlua_ref_global(lstate, 3);
|
||||
ui_add_cb(ns_id, ui_event_cb, ext_widgets);
|
||||
ui_refresh_cmdheight = true;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user