vim-patch:7.4.2101

Problem:    Looping over windows, buffers and tab pages is inconsistant.
Solution:   Use FOR_ALL_ macros everywhere. (Yegappan Lakshmanan)

2932359000
This commit is contained in:
James McCoy
2017-03-10 16:13:37 -05:00
parent 5674057e3a
commit 564e9dc17f
10 changed files with 51 additions and 35 deletions

View File

@@ -161,9 +161,13 @@ newwindow:
/* cursor to preview window */
case 'P':
for (wp = firstwin; wp != NULL; wp = wp->w_next)
if (wp->w_p_pvw)
wp = NULL;
FOR_ALL_WINDOWS_IN_TAB(wp2, curtab) {
if (wp2->w_p_pvw) {
wp = wp2;
break;
}
}
if (wp == NULL)
EMSG(_("E441: There is no preview window"));
else
@@ -3366,9 +3370,13 @@ void tabpage_move(int nr)
if (curtab == first_tabpage)
first_tabpage = curtab->tp_next;
else {
for (tp = first_tabpage; tp != NULL; tp = tp->tp_next)
if (tp->tp_next == curtab)
tp = NULL;
FOR_ALL_TABS(tp2) {
if (tp2->tp_next == curtab) {
tp = tp2;
break;
}
}
if (tp == NULL) /* "cannot happen" */
return;
tp->tp_next = curtab->tp_next;
@@ -5753,10 +5761,11 @@ int win_getid(typval_T *argvars)
if (argvars[1].v_type == VAR_UNKNOWN) {
wp = firstwin;
} else {
tabpage_T *tp;
tabpage_T *tp = NULL;
int tabnr = get_tv_number(&argvars[1]);
for (tp = first_tabpage; tp != NULL; tp = tp->tp_next) {
FOR_ALL_TABS(tp2) {
if (--tabnr == 0) {
tp = tp2;
break;
}
}
@@ -5833,11 +5842,10 @@ win_T * win_id2wp(typval_T *argvars)
int win_id2win(typval_T *argvars)
{
win_T *wp;
int nr = 1;
int id = get_tv_number(&argvars[0]);
for (wp = firstwin; wp != NULL; wp = wp->w_next) {
FOR_ALL_WINDOWS_IN_TAB(wp, curtab) {
if (wp->handle == id) {
return nr;
}
@@ -5850,12 +5858,9 @@ void win_findbuf(typval_T *argvars, list_T *list)
{
int bufnr = get_tv_number(&argvars[0]);
for (tabpage_T *tp = first_tabpage; tp != NULL; tp = tp->tp_next) {
for (win_T *wp = tp == curtab ? firstwin : tp->tp_firstwin;
wp != NULL; wp = wp->w_next) {
if (wp->w_buffer->b_fnum == bufnr) {
list_append_number(list, wp->handle);
}
FOR_ALL_TAB_WINDOWS(tp, wp) {
if (wp->w_buffer->b_fnum == bufnr) {
list_append_number(list, wp->handle);
}
}
}