mirror of
https://github.com/neovim/neovim.git
synced 2025-10-14 05:46:12 +00:00
fix(api): crash when moving curwin to other tabpage #35679
Problem: nvim_win_set_config may crash when attempting to move curwin to a different tabpage if there is no other non-float available to switch to. Solution: fix the crash. Fix ONE_WINDOW checks in winframe_find_altwin and win_altframe to consider floating windows by instead using one_window. Allow one_window to consider non-current tabpages. We can use one_window in win_close_othertab now to also better reflect its use in win_close. Co-authored-by: Sean Dewar <6256228+seandewar@users.noreply.github.com>
This commit is contained in:
@@ -485,7 +485,14 @@ void nvim_win_set_config(Window window, Dict(win_config) *config, Error *err)
|
||||
if (curwin_moving_tp) {
|
||||
if (was_split) {
|
||||
int dir;
|
||||
win_goto(winframe_find_altwin(win, &dir, NULL, NULL));
|
||||
win_T *altwin = winframe_find_altwin(win, &dir, NULL, NULL);
|
||||
// Autocommands may still make this the last non-float after this check.
|
||||
// That case will be caught later when trying to move the window.
|
||||
if (!altwin) {
|
||||
api_set_error(err, kErrorTypeException, "Cannot move last non-floating window");
|
||||
return;
|
||||
}
|
||||
win_goto(altwin);
|
||||
} else {
|
||||
win_goto(win_float_find_altwin(win, NULL));
|
||||
}
|
||||
@@ -518,7 +525,7 @@ void nvim_win_set_config(Window window, Dict(win_config) *config, Error *err)
|
||||
// FIXME(willothy): if the window is the last in the tabpage but there is another tabpage
|
||||
// and the target window is in that other tabpage, should we move the window to that
|
||||
// tabpage and close the previous one, or just error?
|
||||
api_set_error(err, kErrorTypeException, "Cannot move last window");
|
||||
api_set_error(err, kErrorTypeException, "Cannot move last non-floating window");
|
||||
goto restore_curwin;
|
||||
} else if (parent != NULL && parent->handle == win->handle) {
|
||||
int n_frames = 0;
|
||||
|
Reference in New Issue
Block a user