Mercurial > vim
diff src/ex_docmd.c @ 9649:fd9727ae3c49 v7.4.2101
commit https://github.com/vim/vim/commit/2932359000b2f918d5fade79ea4d124d5943cd07
Author: Bram Moolenaar <Bram@vim.org>
Date: Sun Jul 24 22:04:11 2016 +0200
patch 7.4.2101
Problem: Looping over windows, buffers and tab pages is inconsistant.
Solution: Use FOR_ALL_ macros everywhere. (Yegappan Lakshmanan)
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Sun, 24 Jul 2016 22:15:07 +0200 |
parents | 26da1efa9e46 |
children | c27052511998 |
line wrap: on
line diff
--- a/src/ex_docmd.c +++ b/src/ex_docmd.c @@ -1708,7 +1708,7 @@ current_win_nr(win_T *win) win_T *wp; int nr = 0; - for (wp = firstwin; wp != NULL; wp = wp->w_next) + FOR_ALL_WINDOWS(wp) { ++nr; if (wp == win) @@ -1723,7 +1723,7 @@ current_tab_nr(tabpage_T *tab) tabpage_T *tp; int nr = 0; - for (tp = first_tabpage; tp != NULL; tp = tp->tp_next) + FOR_ALL_TABPAGES(tp) { ++nr; if (tp == tab) @@ -7273,7 +7273,7 @@ ex_close(exarg_T *eap) if (eap->addr_count == 0) ex_win_close(eap->forceit, curwin, NULL); else { - for (win = firstwin; win != NULL; win = win->w_next) + FOR_ALL_WINDOWS(win) { winnr++; if (winnr == eap->line2) @@ -7295,7 +7295,7 @@ ex_pclose(exarg_T *eap) { win_T *win; - for (win = firstwin; win != NULL; win = win->w_next) + FOR_ALL_WINDOWS(win) if (win->w_p_pvw) { ex_win_close(eap->forceit, win, NULL); @@ -7415,7 +7415,7 @@ ex_tabonly(exarg_T *eap) * up the lists. */ for (done = 0; done < 1000; ++done) { - for (tp = first_tabpage; tp != NULL; tp = tp->tp_next) + FOR_ALL_TABPAGES(tp) if (tp->tp_topframe != topframe) { tabpage_close_other(tp, eap->forceit); @@ -7474,6 +7474,10 @@ tabpage_close_other(tabpage_T *tp, int f break; } +#ifdef FEAT_AUTOCMD + apply_autocmds(EVENT_TABCLOSED, NULL, NULL, FALSE, curbuf); +#endif + redraw_tabline = TRUE; if (h != tabline_height()) shell_new_rows(); @@ -7540,7 +7544,7 @@ ex_hide(exarg_T *eap) int winnr = 0; win_T *win; - for (win = firstwin; win != NULL; win = win->w_next) + FOR_ALL_WINDOWS(win) { winnr++; if (winnr == eap->line2) @@ -8686,7 +8690,7 @@ ex_syncbind(exarg_T *eap UNUSED) if (curwin->w_p_scb) { topline = curwin->w_topline; - for (wp = firstwin; wp; wp = wp->w_next) + FOR_ALL_WINDOWS(wp) { if (wp->w_p_scb && wp->w_buffer) { @@ -8707,7 +8711,7 @@ ex_syncbind(exarg_T *eap UNUSED) /* * Set all scrollbind windows to the same topline. */ - for (curwin = firstwin; curwin; curwin = curwin->w_next) + FOR_ALL_WINDOWS(curwin) { if (curwin->w_p_scb) { @@ -10957,7 +10961,7 @@ makeopens( return FAIL; /* Now put the other buffers into the buffer list */ - for (buf = firstbuf; buf != NULL; buf = buf->b_next) + FOR_ALL_BUFFERS(buf) { if (!(only_save_windows && buf->b_nwindows == 0) && !(buf->b_help && !(ssop_flags & SSOP_HELP))