fix(api): make open_win/win_set_config check if splitting allowed

Problem: splitting is disallowed in some cases to prevent the window layout
changes while a window is closing, but it's not checked for.

Solution: check for this, and set the API error message directly.

(Also sneak in a change to tui.c that got lost from #27352; it's a char* buf,
and the memset is assuming one byte each anyway)
This commit is contained in:
Sean Dewar
2024-02-07 17:17:44 +00:00
committed by Sean Dewar
parent b1e24f240b
commit 5d58136ccc
4 changed files with 82 additions and 11 deletions

View File

@@ -246,6 +246,10 @@ Window nvim_open_win(Buffer buffer, Boolean enter, Dict(win_config) *config, Err
}
}
if (!check_split_disallowed_err(parent ? parent : curwin, err)) {
return 0; // error already set
}
if (HAS_KEY_X(config, vertical) && !HAS_KEY_X(config, split)) {
if (config->vertical) {
fconfig.split = p_spr ? kWinSplitRight : kWinSplitLeft;
@@ -440,6 +444,10 @@ void nvim_win_set_config(Window window, Dict(win_config) *config, Error *err)
return;
}
if (!check_split_disallowed_err(win, err)) {
return; // error already set
}
if (was_split) {
win_T *new_curwin = NULL;