fix(window): skip unfocusable and hidden floats with "{count}<C-W>w" #33810

Problem: Using `<C-W>w`, `<C-W>W` or the ":wincmd" variants with a count can
enter unfocusable or hidden floating windows. This is especially problematic
when using the new in-development extui, which creates many unfocusable floats
for various UI elements.

Solution: Skip unfocusable and hidden floating windows. Instead, skip to the
next focusable, non-hidden window in the current tabpage's window list. Reword
the documentation a bit (hopefully an improvement?)
This commit is contained in:
Sean Dewar
2025-05-03 19:30:24 +01:00
committed by GitHub
parent 03d378fda6
commit 403fcacfc1
3 changed files with 72 additions and 9 deletions

View File

@@ -348,12 +348,23 @@ newwindow:
} else {
win_T *wp;
if (Prenum) { // go to specified window
win_T *last_focusable = firstwin;
for (wp = firstwin; --Prenum > 0;) {
if (!wp->w_floating || (!wp->w_config.hide && wp->w_config.focusable)) {
last_focusable = wp;
}
if (wp->w_next == NULL) {
break;
}
wp = wp->w_next;
}
while (wp != NULL && wp->w_floating
&& (wp->w_config.hide || !wp->w_config.focusable)) {
wp = wp->w_next;
}
if (wp == NULL) { // went past the last focusable window
wp = last_focusable;
}
} else {
if (nchar == 'W') { // go to previous window
wp = curwin->w_prev;