aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/fileio.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/nvim/fileio.c')
-rw-r--r--src/nvim/fileio.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/src/nvim/fileio.c b/src/nvim/fileio.c
index 0a05b2a4db..97daa035f8 100644
--- a/src/nvim/fileio.c
+++ b/src/nvim/fileio.c
@@ -6177,12 +6177,17 @@ aucmd_prepbuf (
int save_acd;
/* Find a window that is for the new buffer */
- if (buf == curbuf) /* be quick when buf is curbuf */
+ if (buf == curbuf) { /* be quick when buf is curbuf */
win = curwin;
- else
- for (win = firstwin; win != NULL; win = win->w_next)
- if (win->w_buffer == buf)
+ } else {
+ win = NULL;
+ FOR_ALL_WINDOWS(wp) {
+ if (wp->w_buffer == buf) {
+ win = wp;
break;
+ }
+ }
+ }
/* Allocate "aucmd_win" when needed. If this fails (out of memory) fall
* back to using the current window. */