mirror of
https://github.com/neovim/neovim.git
synced 2025-10-05 09:26:30 +00:00
fix(api): patch some cmdwin/textlock holes
Problem: there are new ways to escape textlock or break the cmdwin in nvim_win_set_config and nvim_tabpage_set_win. Solution: fix them. Use win_goto to check it in nvim_tabpage_set_win and use the try_start/end pattern like with similar functions such as nvim_set_current_win (which uses the existing msg_list, if set). Careful not to use `wp->handle` when printing the window ID in the error message for nvim_tabpage_set_win, as win_goto autocommands may have freed the window. On a related note, I have a feeling some API functions ought to be checking curbuf_locked...
This commit is contained in:
@@ -55,6 +55,19 @@ win_T *win_new_float(win_T *wp, bool last, WinConfig fconfig, Error *err)
|
||||
api_set_error(err, kErrorTypeException,
|
||||
"Cannot change window from different tabpage into float");
|
||||
return NULL;
|
||||
} else if (cmdwin_win != NULL && !cmdwin_win->w_floating) {
|
||||
// cmdwin can't become the only non-float. Check for others.
|
||||
bool other_nonfloat = false;
|
||||
for (win_T *wp2 = firstwin; wp2 != NULL && !wp2->w_floating; wp2 = wp2->w_next) {
|
||||
if (wp2 != wp && wp2 != cmdwin_win) {
|
||||
other_nonfloat = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!other_nonfloat) {
|
||||
api_set_error(err, kErrorTypeException, "%s", e_cmdwin);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
int dir;
|
||||
winframe_remove(wp, &dir, NULL, NULL);
|
||||
|
Reference in New Issue
Block a user