aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/eval.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/nvim/eval.c')
-rw-r--r--src/nvim/eval.c38
1 files changed, 22 insertions, 16 deletions
diff --git a/src/nvim/eval.c b/src/nvim/eval.c
index 0dd261f53a..28f16d0e92 100644
--- a/src/nvim/eval.c
+++ b/src/nvim/eval.c
@@ -5403,11 +5403,9 @@ static int list_join(garray_T *gap, list_T *l, char_u *sep, int echo_style, int
int garbage_collect(void)
{
int copyID;
- win_T *wp;
funccall_T *fc, **pfc;
int did_free;
int did_free_funccal = FALSE;
- tabpage_T *tp;
/* Only do this once. */
want_garbage_collect = FALSE;
@@ -5442,14 +5440,16 @@ int garbage_collect(void)
}
/* window-local variables */
- FOR_ALL_TAB_WINDOWS(tp, wp)
- set_ref_in_item(&wp->w_winvar.di_tv, copyID);
+ FOR_ALL_TAB_WINDOWS(tp, wp) {
+ set_ref_in_item(&wp->w_winvar.di_tv, copyID);
+ }
if (aucmd_win != NULL)
set_ref_in_item(&aucmd_win->w_winvar.di_tv, copyID);
/* tabpage-local variables */
- for (tp = first_tabpage; tp != NULL; tp = tp->tp_next)
+ FOR_ALL_TABS(tp) {
set_ref_in_item(&tp->tp_winvar.di_tv, copyID);
+ }
/* global variables */
set_ref_in_ht(&globvarht, copyID);
@@ -9588,21 +9588,27 @@ find_win_by_nr (
tabpage_T *tp /* NULL for current tab page */
)
{
- win_T *wp;
- int nr;
-
- nr = get_tv_number_chk(vp, NULL);
+ int nr = get_tv_number_chk(vp, NULL);
- if (nr < 0)
+ if (nr < 0) {
return NULL;
- if (nr == 0)
+ }
+
+ if (nr == 0) {
return curwin;
+ }
- for (wp = (tp == NULL || tp == curtab) ? firstwin : tp->tp_firstwin;
- wp != NULL; wp = wp->w_next)
- if (--nr <= 0)
- break;
- return wp;
+ // This method accepts NULL as an alias for curtab.
+ if (tp == NULL) {
+ tp = curtab;
+ }
+
+ FOR_ALL_WINDOWS_IN_TAB(wp, tp) {
+ if (--nr <= 0) {
+ return wp;
+ }
+ }
+ return NULL;
}
/*