fix(window): don't enter unfocusable or hidden prevwin (#34486)

Problem:  When closing a floating window, the next window to be entered
          may be unfocusable or hidden.
Solution: Don't enter prevwin when it is unfocusable or hidden. Enter
          firstwin instead (like for when prevwin is no longer valid).
(cherry picked from commit 0d658660c2)
This commit is contained in:
luukvbaal
2025-06-14 23:42:23 +02:00
committed by github-actions[bot]
parent a34b8e42df
commit 742ea00742
3 changed files with 32 additions and 12 deletions

View File

@@ -367,13 +367,15 @@ win_T *win_float_find_preview(void)
win_T *win_float_find_altwin(const win_T *win, const tabpage_T *tp)
FUNC_ATTR_NONNULL_ARG(1)
{
win_T *wp = prevwin;
if (tp == NULL) {
return (win_valid(prevwin) && prevwin != win) ? prevwin : firstwin;
return (win_valid(wp) && wp != win && wp->w_config.focusable
&& !wp->w_config.hide) ? wp : firstwin;
}
assert(tp != curtab);
return (tabpage_win_valid(tp, tp->tp_prevwin) && tp->tp_prevwin != win) ? tp->tp_prevwin
: tp->tp_firstwin;
wp = tabpage_win_valid(tp, tp->tp_prevwin) ? tp->tp_prevwin : tp->tp_firstwin;
return (wp->w_config.focusable && !wp->w_config.hide) ? wp : tp->tp_firstwin;
}
/// Inline helper function for handling errors and cleanup in win_float_create.