mirror of
https://github.com/neovim/neovim.git
synced 2025-09-09 12:58:16 +00:00
FOR_ALL_WINDOWS_IN_TAB and local variables in FOR_ALL_TAB_WINDOWS
This commit is contained in:
@@ -7,6 +7,7 @@
|
|||||||
#include "nvim/api/private/defs.h"
|
#include "nvim/api/private/defs.h"
|
||||||
#include "nvim/api/private/helpers.h"
|
#include "nvim/api/private/helpers.h"
|
||||||
#include "nvim/memory.h"
|
#include "nvim/memory.h"
|
||||||
|
#include "nvim/window.h"
|
||||||
|
|
||||||
/// Gets the number of windows in a tabpage
|
/// Gets the number of windows in a tabpage
|
||||||
///
|
///
|
||||||
@@ -18,27 +19,18 @@ ArrayOf(Window) tabpage_get_windows(Tabpage tabpage, Error *err)
|
|||||||
Array rv = ARRAY_DICT_INIT;
|
Array rv = ARRAY_DICT_INIT;
|
||||||
tabpage_T *tab = find_tab_by_handle(tabpage, err);
|
tabpage_T *tab = find_tab_by_handle(tabpage, err);
|
||||||
|
|
||||||
if (!tab) {
|
if (!tab || !valid_tabpage(tab)) {
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
tabpage_T *tp;
|
FOR_ALL_WINDOWS_IN_TAB(wp, tab) {
|
||||||
win_T *wp;
|
|
||||||
|
|
||||||
FOR_ALL_TAB_WINDOWS(tp, wp) {
|
|
||||||
if (tp != tab) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
rv.size++;
|
rv.size++;
|
||||||
}
|
}
|
||||||
|
|
||||||
rv.items = xmalloc(sizeof(Object) * rv.size);
|
rv.items = xmalloc(sizeof(Object) * rv.size);
|
||||||
size_t i = 0;
|
size_t i = 0;
|
||||||
|
|
||||||
FOR_ALL_TAB_WINDOWS(tp, wp) {
|
FOR_ALL_WINDOWS_IN_TAB(wp, tab) {
|
||||||
if (tp != tab) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
rv.items[i++] = WINDOW_OBJ(wp->handle);
|
rv.items[i++] = WINDOW_OBJ(wp->handle);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -90,18 +82,15 @@ Window tabpage_get_window(Tabpage tabpage, Error *err)
|
|||||||
Window rv = 0;
|
Window rv = 0;
|
||||||
tabpage_T *tab = find_tab_by_handle(tabpage, err);
|
tabpage_T *tab = find_tab_by_handle(tabpage, err);
|
||||||
|
|
||||||
if (!tab) {
|
if (!tab || !valid_tabpage(tab)) {
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tab == curtab) {
|
if (tab == curtab) {
|
||||||
return vim_get_current_window();
|
return vim_get_current_window();
|
||||||
} else {
|
} else {
|
||||||
tabpage_T *tp;
|
FOR_ALL_WINDOWS_IN_TAB(wp, tab) {
|
||||||
win_T *wp;
|
if (wp == tab->tp_curwin) {
|
||||||
|
|
||||||
FOR_ALL_TAB_WINDOWS(tp, wp) {
|
|
||||||
if (tp == tab && wp == tab->tp_curwin) {
|
|
||||||
return wp->handle;
|
return wp->handle;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -380,8 +380,6 @@ void vim_set_current_buffer(Buffer buffer, Error *err)
|
|||||||
ArrayOf(Window) vim_get_windows(void)
|
ArrayOf(Window) vim_get_windows(void)
|
||||||
{
|
{
|
||||||
Array rv = ARRAY_DICT_INIT;
|
Array rv = ARRAY_DICT_INIT;
|
||||||
tabpage_T *tp;
|
|
||||||
win_T *wp;
|
|
||||||
|
|
||||||
FOR_ALL_TAB_WINDOWS(tp, wp) {
|
FOR_ALL_TAB_WINDOWS(tp, wp) {
|
||||||
rv.size++;
|
rv.size++;
|
||||||
|
@@ -514,12 +514,8 @@ void buf_freeall(buf_T *buf, int flags)
|
|||||||
reset_synblock(curwin);
|
reset_synblock(curwin);
|
||||||
|
|
||||||
/* No folds in an empty buffer. */
|
/* No folds in an empty buffer. */
|
||||||
{
|
|
||||||
win_T *win;
|
|
||||||
tabpage_T *tp;
|
|
||||||
|
|
||||||
FOR_ALL_TAB_WINDOWS(tp, win) {
|
FOR_ALL_TAB_WINDOWS(tp, win) {
|
||||||
if (win->w_buffer == buf)
|
if (win->w_buffer == buf) {
|
||||||
clearFolding(win);
|
clearFolding(win);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -4206,8 +4202,6 @@ int read_viminfo_bufferlist(vir_T *virp, int writing)
|
|||||||
|
|
||||||
void write_viminfo_bufferlist(FILE *fp)
|
void write_viminfo_bufferlist(FILE *fp)
|
||||||
{
|
{
|
||||||
win_T *win;
|
|
||||||
tabpage_T *tp;
|
|
||||||
char_u *line;
|
char_u *line;
|
||||||
int max_buffers;
|
int max_buffers;
|
||||||
|
|
||||||
@@ -4284,8 +4278,12 @@ char_u *buf_spname(buf_T *buf)
|
|||||||
*/
|
*/
|
||||||
bool find_win_for_buf(buf_T *buf, win_T **wp, tabpage_T **tp)
|
bool find_win_for_buf(buf_T *buf, win_T **wp, tabpage_T **tp)
|
||||||
{
|
{
|
||||||
FOR_ALL_TAB_WINDOWS(*tp, *wp) {
|
*wp = NULL;
|
||||||
if ((*wp)->w_buffer == buf) {
|
*tp = NULL;
|
||||||
|
FOR_ALL_TAB_WINDOWS(tp2, wp2) {
|
||||||
|
if (wp2->w_buffer == buf) {
|
||||||
|
*tp = tp2;
|
||||||
|
*wp = wp2;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -5403,7 +5403,6 @@ static int list_join(garray_T *gap, list_T *l, char_u *sep, int echo_style, int
|
|||||||
int garbage_collect(void)
|
int garbage_collect(void)
|
||||||
{
|
{
|
||||||
int copyID;
|
int copyID;
|
||||||
win_T *wp;
|
|
||||||
funccall_T *fc, **pfc;
|
funccall_T *fc, **pfc;
|
||||||
int did_free;
|
int did_free;
|
||||||
int did_free_funccal = FALSE;
|
int did_free_funccal = FALSE;
|
||||||
@@ -5441,12 +5440,9 @@ int garbage_collect(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* window-local variables */
|
/* window-local variables */
|
||||||
{
|
|
||||||
tabpage_T *tp;
|
|
||||||
FOR_ALL_TAB_WINDOWS(tp, wp) {
|
FOR_ALL_TAB_WINDOWS(tp, wp) {
|
||||||
set_ref_in_item(&wp->w_winvar.di_tv, copyID);
|
set_ref_in_item(&wp->w_winvar.di_tv, copyID);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
if (aucmd_win != NULL)
|
if (aucmd_win != NULL)
|
||||||
set_ref_in_item(&aucmd_win->w_winvar.di_tv, copyID);
|
set_ref_in_item(&aucmd_win->w_winvar.di_tv, copyID);
|
||||||
|
|
||||||
@@ -9592,21 +9588,27 @@ find_win_by_nr (
|
|||||||
tabpage_T *tp /* NULL for current tab page */
|
tabpage_T *tp /* NULL for current tab page */
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
win_T *wp;
|
int nr = get_tv_number_chk(vp, NULL);
|
||||||
int nr;
|
|
||||||
|
|
||||||
nr = get_tv_number_chk(vp, NULL);
|
if (nr < 0) {
|
||||||
|
|
||||||
if (nr < 0)
|
|
||||||
return NULL;
|
return NULL;
|
||||||
if (nr == 0)
|
}
|
||||||
return curwin;
|
|
||||||
|
|
||||||
for (wp = (tp == NULL || tp == curtab) ? firstwin : tp->tp_firstwin;
|
if (nr == 0) {
|
||||||
wp != NULL; wp = wp->w_next)
|
return curwin;
|
||||||
if (--nr <= 0)
|
}
|
||||||
break;
|
|
||||||
|
// 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 wp;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@@ -2962,14 +2962,11 @@ do_ecmd (
|
|||||||
|
|
||||||
/* It's possible that all lines in the buffer changed. Need to update
|
/* It's possible that all lines in the buffer changed. Need to update
|
||||||
* automatic folding for all windows where it's used. */
|
* automatic folding for all windows where it's used. */
|
||||||
{
|
FOR_ALL_TAB_WINDOWS(tp, win) {
|
||||||
win_T *win;
|
if (win->w_buffer == curbuf) {
|
||||||
tabpage_T *tp;
|
|
||||||
|
|
||||||
FOR_ALL_TAB_WINDOWS(tp, win)
|
|
||||||
if (win->w_buffer == curbuf)
|
|
||||||
foldUpdateAll(win);
|
foldUpdateAll(win);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* Change directories when the 'acd' option is set. */
|
/* Change directories when the 'acd' option is set. */
|
||||||
do_autochdir();
|
do_autochdir();
|
||||||
|
@@ -1226,7 +1226,7 @@ check_changed_any (
|
|||||||
/* buf in other tab */
|
/* buf in other tab */
|
||||||
FOR_ALL_TABS(tp) {
|
FOR_ALL_TABS(tp) {
|
||||||
if (tp != curtab) {
|
if (tp != curtab) {
|
||||||
for (win_T *wp = tp->tp_firstwin; wp != NULL; wp = wp->w_next) {
|
FOR_ALL_WINDOWS_IN_TAB(wp, tp) {
|
||||||
add_bufnum(bufnrs, &bufnum, wp->w_buffer->b_fnum);
|
add_bufnum(bufnrs, &bufnum, wp->w_buffer->b_fnum);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1281,8 +1281,6 @@ check_changed_any (
|
|||||||
|
|
||||||
/* Try to find a window that contains the buffer. */
|
/* Try to find a window that contains the buffer. */
|
||||||
if (buf != curbuf) {
|
if (buf != curbuf) {
|
||||||
win_T *wp;
|
|
||||||
tabpage_T *tp;
|
|
||||||
FOR_ALL_TAB_WINDOWS(tp, wp) {
|
FOR_ALL_TAB_WINDOWS(tp, wp) {
|
||||||
if (wp->w_buffer == buf) {
|
if (wp->w_buffer == buf) {
|
||||||
goto_tabpage_win(tp, wp);
|
goto_tabpage_win(tp, wp);
|
||||||
@@ -1510,12 +1508,11 @@ do_arglist (
|
|||||||
*/
|
*/
|
||||||
static void alist_check_arg_idx(void)
|
static void alist_check_arg_idx(void)
|
||||||
{
|
{
|
||||||
win_T *win;
|
FOR_ALL_TAB_WINDOWS(tp, win) {
|
||||||
tabpage_T *tp;
|
if (win->w_alist == curwin->w_alist) {
|
||||||
|
|
||||||
FOR_ALL_TAB_WINDOWS(tp, win)
|
|
||||||
if (win->w_alist == curwin->w_alist)
|
|
||||||
check_arg_idx(win);
|
check_arg_idx(win);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@@ -5606,18 +5606,21 @@ alist_add (
|
|||||||
*/
|
*/
|
||||||
void alist_slash_adjust(void)
|
void alist_slash_adjust(void)
|
||||||
{
|
{
|
||||||
int i;
|
for (int i = 0; i < GARGCOUNT; ++i) {
|
||||||
win_T *wp;
|
if (GARGLIST[i].ae_fname != NULL) {
|
||||||
tabpage_T *tp;
|
|
||||||
|
|
||||||
for (i = 0; i < GARGCOUNT; ++i)
|
|
||||||
if (GARGLIST[i].ae_fname != NULL)
|
|
||||||
slash_adjust(GARGLIST[i].ae_fname);
|
slash_adjust(GARGLIST[i].ae_fname);
|
||||||
FOR_ALL_TAB_WINDOWS(tp, wp)
|
}
|
||||||
if (wp->w_alist != &global_alist)
|
}
|
||||||
for (i = 0; i < WARGCOUNT(wp); ++i)
|
|
||||||
if (WARGLIST(wp)[i].ae_fname != NULL)
|
FOR_ALL_TAB_WINDOWS(tp, wp) {
|
||||||
|
if (wp->w_alist != &global_alist) {
|
||||||
|
for (int i = 0; i < WARGCOUNT(wp); ++i) {
|
||||||
|
if (WARGLIST(wp)[i].ae_fname != NULL) {
|
||||||
slash_adjust(WARGLIST(wp)[i].ae_fname);
|
slash_adjust(WARGLIST(wp)[i].ae_fname);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
@@ -5823,13 +5826,11 @@ static void ex_tabs(exarg_T *eap)
|
|||||||
out_flush(); /* output one line at a time */
|
out_flush(); /* output one line at a time */
|
||||||
ui_breakcheck();
|
ui_breakcheck();
|
||||||
|
|
||||||
win_T *wp;
|
FOR_ALL_WINDOWS_IN_TAB(wp, tp) {
|
||||||
if (tp == curtab) {
|
if (got_int) {
|
||||||
wp = firstwin;
|
break;
|
||||||
} else {
|
|
||||||
wp = tp->tp_firstwin;
|
|
||||||
}
|
}
|
||||||
for (; wp != NULL && !got_int; wp = wp->w_next) {
|
|
||||||
msg_putchar('\n');
|
msg_putchar('\n');
|
||||||
msg_putchar(wp == curwin ? '>' : ' ');
|
msg_putchar(wp == curwin ? '>' : ' ');
|
||||||
msg_putchar(' ');
|
msg_putchar(' ');
|
||||||
|
@@ -5102,16 +5102,15 @@ void buf_reload(buf_T *buf, int orig_mode)
|
|||||||
check_cursor();
|
check_cursor();
|
||||||
update_topline();
|
update_topline();
|
||||||
keep_filetype = FALSE;
|
keep_filetype = FALSE;
|
||||||
{
|
|
||||||
win_T *wp;
|
|
||||||
tabpage_T *tp;
|
|
||||||
|
|
||||||
/* Update folds unless they are defined manually. */
|
/* Update folds unless they are defined manually. */
|
||||||
FOR_ALL_TAB_WINDOWS(tp, wp)
|
FOR_ALL_TAB_WINDOWS(tp, wp) {
|
||||||
if (wp->w_buffer == curwin->w_buffer
|
if (wp->w_buffer == curwin->w_buffer
|
||||||
&& !foldmethodIsManual(wp))
|
&& !foldmethodIsManual(wp)) {
|
||||||
foldUpdateAll(wp);
|
foldUpdateAll(wp);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* If the mode didn't change and 'readonly' was set, keep the old
|
/* If the mode didn't change and 'readonly' was set, keep the old
|
||||||
* value; the user probably used the ":view" command. But don't
|
* value; the user probably used the ":view" command. But don't
|
||||||
* reset it, might have had a read error. */
|
* reset it, might have had a read error. */
|
||||||
@@ -6269,14 +6268,11 @@ aucmd_restbuf (
|
|||||||
* page. Do not trigger autocommands here. */
|
* page. Do not trigger autocommands here. */
|
||||||
block_autocmds();
|
block_autocmds();
|
||||||
if (curwin != aucmd_win) {
|
if (curwin != aucmd_win) {
|
||||||
tabpage_T *tp;
|
FOR_ALL_TAB_WINDOWS(tp, wp) {
|
||||||
win_T *wp;
|
|
||||||
|
|
||||||
FOR_ALL_TAB_WINDOWS(tp, wp)
|
|
||||||
{
|
|
||||||
if (wp == aucmd_win) {
|
if (wp == aucmd_win) {
|
||||||
if (tp != curtab)
|
if (tp != curtab) {
|
||||||
goto_tabpage_tp(tp, TRUE, TRUE);
|
goto_tabpage_tp(tp, TRUE, TRUE);
|
||||||
|
}
|
||||||
win_goto(aucmd_win);
|
win_goto(aucmd_win);
|
||||||
goto win_found;
|
goto win_found;
|
||||||
}
|
}
|
||||||
|
@@ -525,9 +525,12 @@ EXTERN win_T *prevwin INIT(= NULL); /* previous window */
|
|||||||
* to break out of the tabpage loop.
|
* to break out of the tabpage loop.
|
||||||
*/
|
*/
|
||||||
# define FOR_ALL_TAB_WINDOWS(tp, wp) \
|
# define FOR_ALL_TAB_WINDOWS(tp, wp) \
|
||||||
for ((tp) = first_tabpage; (tp) != NULL; (tp) = (tp)->tp_next) \
|
FOR_ALL_TABS(tp) \
|
||||||
for ((wp) = ((tp) == curtab) \
|
FOR_ALL_WINDOWS_IN_TAB(wp, tp)
|
||||||
? firstwin : (tp)->tp_firstwin; (wp); (wp) = (wp)->w_next)
|
|
||||||
|
# define FOR_ALL_WINDOWS_IN_TAB(wp, tp) \
|
||||||
|
for (win_T *wp = ((tp) == curtab) \
|
||||||
|
? firstwin : (tp)->tp_firstwin; wp != NULL; wp = wp->w_next)
|
||||||
|
|
||||||
EXTERN win_T *curwin; /* currently active window */
|
EXTERN win_T *curwin; /* currently active window */
|
||||||
|
|
||||||
|
@@ -758,7 +758,6 @@ main_loop (
|
|||||||
/* Exit properly */
|
/* Exit properly */
|
||||||
void getout(int exitval)
|
void getout(int exitval)
|
||||||
{
|
{
|
||||||
win_T *wp;
|
|
||||||
tabpage_T *tp, *next_tp;
|
tabpage_T *tp, *next_tp;
|
||||||
|
|
||||||
exiting = TRUE;
|
exiting = TRUE;
|
||||||
@@ -780,11 +779,12 @@ void getout(int exitval)
|
|||||||
/* Trigger BufWinLeave for all windows, but only once per buffer. */
|
/* Trigger BufWinLeave for all windows, but only once per buffer. */
|
||||||
for (tp = first_tabpage; tp != NULL; tp = next_tp) {
|
for (tp = first_tabpage; tp != NULL; tp = next_tp) {
|
||||||
next_tp = tp->tp_next;
|
next_tp = tp->tp_next;
|
||||||
for (wp = (tp == curtab)
|
FOR_ALL_WINDOWS_IN_TAB(wp, tp) {
|
||||||
? firstwin : tp->tp_firstwin; wp != NULL; wp = wp->w_next) {
|
if (wp->w_buffer == NULL) {
|
||||||
if (wp->w_buffer == NULL)
|
|
||||||
/* Autocmd must have close the buffer already, skip. */
|
/* Autocmd must have close the buffer already, skip. */
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
buf_T *buf = wp->w_buffer;
|
buf_T *buf = wp->w_buffer;
|
||||||
if (buf->b_changedtick != -1) {
|
if (buf->b_changedtick != -1) {
|
||||||
apply_autocmds(EVENT_BUFWINLEAVE, buf->b_fname,
|
apply_autocmds(EVENT_BUFWINLEAVE, buf->b_fname,
|
||||||
|
@@ -898,8 +898,6 @@ void mark_adjust(linenr_T line1, linenr_T line2, long amount, long amount_after)
|
|||||||
int i;
|
int i;
|
||||||
int fnum = curbuf->b_fnum;
|
int fnum = curbuf->b_fnum;
|
||||||
linenr_T *lp;
|
linenr_T *lp;
|
||||||
win_T *win;
|
|
||||||
tabpage_T *tab;
|
|
||||||
static pos_T initpos = INIT_POS_T(1, 0, 0);
|
static pos_T initpos = INIT_POS_T(1, 0, 0);
|
||||||
|
|
||||||
if (line2 < line1 && amount_after == 0L) /* nothing to do */
|
if (line2 < line1 && amount_after == 0L) /* nothing to do */
|
||||||
@@ -939,8 +937,9 @@ void mark_adjust(linenr_T line1, linenr_T line2, long amount, long amount_after)
|
|||||||
/* quickfix marks */
|
/* quickfix marks */
|
||||||
qf_mark_adjust(NULL, line1, line2, amount, amount_after);
|
qf_mark_adjust(NULL, line1, line2, amount, amount_after);
|
||||||
/* location lists */
|
/* location lists */
|
||||||
FOR_ALL_TAB_WINDOWS(tab, win)
|
FOR_ALL_TAB_WINDOWS(tab, win) {
|
||||||
qf_mark_adjust(win, line1, line2, amount, amount_after);
|
qf_mark_adjust(win, line1, line2, amount, amount_after);
|
||||||
|
}
|
||||||
|
|
||||||
sign_mark_adjust(line1, line2, amount, amount_after);
|
sign_mark_adjust(line1, line2, amount, amount_after);
|
||||||
}
|
}
|
||||||
@@ -958,21 +957,26 @@ void mark_adjust(linenr_T line1, linenr_T line2, long amount, long amount_after)
|
|||||||
/*
|
/*
|
||||||
* Adjust items in all windows related to the current buffer.
|
* Adjust items in all windows related to the current buffer.
|
||||||
*/
|
*/
|
||||||
FOR_ALL_TAB_WINDOWS(tab, win)
|
FOR_ALL_TAB_WINDOWS(tab, win) {
|
||||||
{
|
if (!cmdmod.lockmarks) {
|
||||||
if (!cmdmod.lockmarks)
|
|
||||||
/* Marks in the jumplist. When deleting lines, this may create
|
/* Marks in the jumplist. When deleting lines, this may create
|
||||||
* duplicate marks in the jumplist, they will be removed later. */
|
* duplicate marks in the jumplist, they will be removed later. */
|
||||||
for (i = 0; i < win->w_jumplistlen; ++i)
|
for (i = 0; i < win->w_jumplistlen; ++i) {
|
||||||
if (win->w_jumplist[i].fmark.fnum == fnum)
|
if (win->w_jumplist[i].fmark.fnum == fnum) {
|
||||||
one_adjust_nodel(&(win->w_jumplist[i].fmark.mark.lnum));
|
one_adjust_nodel(&(win->w_jumplist[i].fmark.mark.lnum));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (win->w_buffer == curbuf) {
|
if (win->w_buffer == curbuf) {
|
||||||
if (!cmdmod.lockmarks)
|
if (!cmdmod.lockmarks) {
|
||||||
/* marks in the tag stack */
|
/* marks in the tag stack */
|
||||||
for (i = 0; i < win->w_tagstacklen; i++)
|
for (i = 0; i < win->w_tagstacklen; i++) {
|
||||||
if (win->w_tagstack[i].fmark.fnum == fnum)
|
if (win->w_tagstack[i].fmark.fnum == fnum) {
|
||||||
one_adjust_nodel(&(win->w_tagstack[i].fmark.mark.lnum));
|
one_adjust_nodel(&(win->w_tagstack[i].fmark.mark.lnum));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* the displayed Visual area */
|
/* the displayed Visual area */
|
||||||
if (win->w_old_cursor_lnum != 0) {
|
if (win->w_old_cursor_lnum != 0) {
|
||||||
@@ -985,12 +989,14 @@ void mark_adjust(linenr_T line1, linenr_T line2, long amount, long amount_after)
|
|||||||
if (win != curwin) {
|
if (win != curwin) {
|
||||||
if (win->w_topline >= line1 && win->w_topline <= line2) {
|
if (win->w_topline >= line1 && win->w_topline <= line2) {
|
||||||
if (amount == MAXLNUM) { /* topline is deleted */
|
if (amount == MAXLNUM) { /* topline is deleted */
|
||||||
if (line1 <= 1)
|
if (line1 <= 1) {
|
||||||
win->w_topline = 1;
|
win->w_topline = 1;
|
||||||
else
|
} else {
|
||||||
win->w_topline = line1 - 1;
|
win->w_topline = line1 - 1;
|
||||||
} else /* keep topline on the same line */
|
}
|
||||||
|
} else { /* keep topline on the same line */
|
||||||
win->w_topline += amount;
|
win->w_topline += amount;
|
||||||
|
}
|
||||||
win->w_topfill = 0;
|
win->w_topfill = 0;
|
||||||
} else if (amount_after && win->w_topline > line2) {
|
} else if (amount_after && win->w_topline > line2) {
|
||||||
win->w_topline += amount_after;
|
win->w_topline += amount_after;
|
||||||
@@ -998,16 +1004,19 @@ void mark_adjust(linenr_T line1, linenr_T line2, long amount, long amount_after)
|
|||||||
}
|
}
|
||||||
if (win->w_cursor.lnum >= line1 && win->w_cursor.lnum <= line2) {
|
if (win->w_cursor.lnum >= line1 && win->w_cursor.lnum <= line2) {
|
||||||
if (amount == MAXLNUM) { /* line with cursor is deleted */
|
if (amount == MAXLNUM) { /* line with cursor is deleted */
|
||||||
if (line1 <= 1)
|
if (line1 <= 1) {
|
||||||
win->w_cursor.lnum = 1;
|
win->w_cursor.lnum = 1;
|
||||||
else
|
} else {
|
||||||
win->w_cursor.lnum = line1 - 1;
|
win->w_cursor.lnum = line1 - 1;
|
||||||
|
}
|
||||||
win->w_cursor.col = 0;
|
win->w_cursor.col = 0;
|
||||||
} else /* keep cursor on the same line */
|
} else { /* keep cursor on the same line */
|
||||||
win->w_cursor.lnum += amount;
|
win->w_cursor.lnum += amount;
|
||||||
} else if (amount_after && win->w_cursor.lnum > line2)
|
}
|
||||||
|
} else if (amount_after && win->w_cursor.lnum > line2) {
|
||||||
win->w_cursor.lnum += amount_after;
|
win->w_cursor.lnum += amount_after;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* adjust folds */
|
/* adjust folds */
|
||||||
foldMarkAdjust(win, line1, line2, amount, amount_after);
|
foldMarkAdjust(win, line1, line2, amount, amount_after);
|
||||||
@@ -1338,12 +1347,6 @@ int removable(char_u *name)
|
|||||||
*/
|
*/
|
||||||
int write_viminfo_marks(FILE *fp_out)
|
int write_viminfo_marks(FILE *fp_out)
|
||||||
{
|
{
|
||||||
int count;
|
|
||||||
int is_mark_set;
|
|
||||||
int i;
|
|
||||||
win_T *win;
|
|
||||||
tabpage_T *tp;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Set b_last_cursor for the all buffers that have a window.
|
* Set b_last_cursor for the all buffers that have a window.
|
||||||
*/
|
*/
|
||||||
@@ -1352,23 +1355,23 @@ int write_viminfo_marks(FILE *fp_out)
|
|||||||
}
|
}
|
||||||
|
|
||||||
fputs(_("\n# History of marks within files (newest to oldest):\n"), fp_out);
|
fputs(_("\n# History of marks within files (newest to oldest):\n"), fp_out);
|
||||||
count = 0;
|
int count = 0;
|
||||||
FOR_ALL_BUFFERS(buf) {
|
FOR_ALL_BUFFERS(buf) {
|
||||||
/*
|
/*
|
||||||
* Only write something if buffer has been loaded and at least one
|
* Only write something if buffer has been loaded and at least one
|
||||||
* mark is set.
|
* mark is set.
|
||||||
*/
|
*/
|
||||||
if (buf->b_marks_read) {
|
if (buf->b_marks_read) {
|
||||||
if (buf->b_last_cursor.lnum != 0)
|
bool is_mark_set = true;
|
||||||
is_mark_set = TRUE;
|
if (buf->b_last_cursor.lnum == 0) {
|
||||||
else {
|
is_mark_set = false;
|
||||||
is_mark_set = FALSE;
|
for (int i = 0; i < NMARKS; i++) {
|
||||||
for (i = 0; i < NMARKS; i++)
|
|
||||||
if (buf->b_namedm[i].lnum != 0) {
|
if (buf->b_namedm[i].lnum != 0) {
|
||||||
is_mark_set = TRUE;
|
is_mark_set = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if (is_mark_set && buf->b_ffname != NULL
|
if (is_mark_set && buf->b_ffname != NULL
|
||||||
&& buf->b_ffname[0] != NUL && !removable(buf->b_ffname)) {
|
&& buf->b_ffname[0] != NUL && !removable(buf->b_ffname)) {
|
||||||
home_replace(NULL, buf->b_ffname, IObuff, IOSIZE, TRUE);
|
home_replace(NULL, buf->b_ffname, IObuff, IOSIZE, TRUE);
|
||||||
@@ -1378,10 +1381,12 @@ int write_viminfo_marks(FILE *fp_out)
|
|||||||
write_one_mark(fp_out, '^', &buf->b_last_insert);
|
write_one_mark(fp_out, '^', &buf->b_last_insert);
|
||||||
write_one_mark(fp_out, '.', &buf->b_last_change);
|
write_one_mark(fp_out, '.', &buf->b_last_change);
|
||||||
/* changelist positions are stored oldest first */
|
/* changelist positions are stored oldest first */
|
||||||
for (i = 0; i < buf->b_changelistlen; ++i)
|
for (int i = 0; i < buf->b_changelistlen; ++i) {
|
||||||
write_one_mark(fp_out, '+', &buf->b_changelist[i]);
|
write_one_mark(fp_out, '+', &buf->b_changelist[i]);
|
||||||
for (i = 0; i < NMARKS; i++)
|
}
|
||||||
|
for (int i = 0; i < NMARKS; i++) {
|
||||||
write_one_mark(fp_out, 'a' + i, &buf->b_namedm[i]);
|
write_one_mark(fp_out, 'a' + i, &buf->b_namedm[i]);
|
||||||
|
}
|
||||||
count++;
|
count++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -452,13 +452,9 @@ void free_all_mem(void)
|
|||||||
p_hi = 0;
|
p_hi = 0;
|
||||||
init_history();
|
init_history();
|
||||||
|
|
||||||
{
|
|
||||||
win_T *win;
|
|
||||||
tabpage_T *tab;
|
|
||||||
|
|
||||||
qf_free_all(NULL);
|
qf_free_all(NULL);
|
||||||
/* Free all location lists */
|
/* Free all location lists */
|
||||||
FOR_ALL_TAB_WINDOWS(tab, win)
|
FOR_ALL_TAB_WINDOWS(tab, win) {
|
||||||
qf_free_all(win);
|
qf_free_all(win);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -2027,8 +2027,6 @@ changed_lines_buf (
|
|||||||
*/
|
*/
|
||||||
static void changed_common(linenr_T lnum, colnr_T col, linenr_T lnume, long xtra)
|
static void changed_common(linenr_T lnum, colnr_T col, linenr_T lnume, long xtra)
|
||||||
{
|
{
|
||||||
win_T *wp;
|
|
||||||
tabpage_T *tp;
|
|
||||||
int i;
|
int i;
|
||||||
int cols;
|
int cols;
|
||||||
pos_T *p;
|
pos_T *p;
|
||||||
@@ -2072,22 +2070,22 @@ static void changed_common(linenr_T lnum, colnr_T col, linenr_T lnume, long xtra
|
|||||||
curbuf->b_changelistlen = JUMPLISTSIZE - 1;
|
curbuf->b_changelistlen = JUMPLISTSIZE - 1;
|
||||||
memmove(curbuf->b_changelist, curbuf->b_changelist + 1,
|
memmove(curbuf->b_changelist, curbuf->b_changelist + 1,
|
||||||
sizeof(pos_T) * (JUMPLISTSIZE - 1));
|
sizeof(pos_T) * (JUMPLISTSIZE - 1));
|
||||||
FOR_ALL_TAB_WINDOWS(tp, wp)
|
FOR_ALL_TAB_WINDOWS(tp, wp) {
|
||||||
{
|
|
||||||
/* Correct position in changelist for other windows on
|
/* Correct position in changelist for other windows on
|
||||||
* this buffer. */
|
* this buffer. */
|
||||||
if (wp->w_buffer == curbuf && wp->w_changelistidx > 0)
|
if (wp->w_buffer == curbuf && wp->w_changelistidx > 0) {
|
||||||
--wp->w_changelistidx;
|
--wp->w_changelistidx;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
FOR_ALL_TAB_WINDOWS(tp, wp)
|
}
|
||||||
{
|
FOR_ALL_TAB_WINDOWS(tp, wp) {
|
||||||
/* For other windows, if the position in the changelist is
|
/* For other windows, if the position in the changelist is
|
||||||
* at the end it stays at the end. */
|
* at the end it stays at the end. */
|
||||||
if (wp->w_buffer == curbuf
|
if (wp->w_buffer == curbuf
|
||||||
&& wp->w_changelistidx == curbuf->b_changelistlen)
|
&& wp->w_changelistidx == curbuf->b_changelistlen) {
|
||||||
++wp->w_changelistidx;
|
++wp->w_changelistidx;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
++curbuf->b_changelistlen;
|
++curbuf->b_changelistlen;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2098,8 +2096,7 @@ static void changed_common(linenr_T lnum, colnr_T col, linenr_T lnume, long xtra
|
|||||||
curwin->w_changelistidx = curbuf->b_changelistlen;
|
curwin->w_changelistidx = curbuf->b_changelistlen;
|
||||||
}
|
}
|
||||||
|
|
||||||
FOR_ALL_TAB_WINDOWS(tp, wp)
|
FOR_ALL_TAB_WINDOWS(tp, wp) {
|
||||||
{
|
|
||||||
if (wp->w_buffer == curbuf) {
|
if (wp->w_buffer == curbuf) {
|
||||||
/* Mark this window to be redrawn later. */
|
/* Mark this window to be redrawn later. */
|
||||||
if (wp->w_redr_type < VALID)
|
if (wp->w_redr_type < VALID)
|
||||||
|
@@ -2210,17 +2210,16 @@ set_options_default (
|
|||||||
int opt_flags /* OPT_FREE, OPT_LOCAL and/or OPT_GLOBAL */
|
int opt_flags /* OPT_FREE, OPT_LOCAL and/or OPT_GLOBAL */
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
int i;
|
for (int i = 0; !istermoption(&options[i]); i++) {
|
||||||
win_T *wp;
|
if (!(options[i].flags & P_NODEFAULT)) {
|
||||||
tabpage_T *tp;
|
|
||||||
|
|
||||||
for (i = 0; !istermoption(&options[i]); i++)
|
|
||||||
if (!(options[i].flags & P_NODEFAULT))
|
|
||||||
set_option_default(i, opt_flags, p_cp);
|
set_option_default(i, opt_flags, p_cp);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* The 'scroll' option must be computed for all windows. */
|
/* The 'scroll' option must be computed for all windows. */
|
||||||
FOR_ALL_TAB_WINDOWS(tp, wp)
|
FOR_ALL_TAB_WINDOWS(tp, wp) {
|
||||||
win_comp_scroll(wp);
|
win_comp_scroll(wp);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Set the Vi-default value of a string option.
|
/// Set the Vi-default value of a string option.
|
||||||
@@ -5532,13 +5531,11 @@ set_num_option (
|
|||||||
errmsg = e_positive;
|
errmsg = e_positive;
|
||||||
curbuf->b_p_tw = 0;
|
curbuf->b_p_tw = 0;
|
||||||
}
|
}
|
||||||
{
|
|
||||||
win_T *wp;
|
|
||||||
tabpage_T *tp;
|
|
||||||
|
|
||||||
FOR_ALL_TAB_WINDOWS(tp, wp)
|
FOR_ALL_TAB_WINDOWS(tp, wp) {
|
||||||
check_colorcolumn(wp);
|
check_colorcolumn(wp);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@@ -1466,11 +1466,7 @@ void qf_jump(qf_info_T *qi, int dir, int errornr, int forceit)
|
|||||||
* then search in other tabs.
|
* then search in other tabs.
|
||||||
*/
|
*/
|
||||||
if (!usable_win && (swb_flags & SWB_USETAB)) {
|
if (!usable_win && (swb_flags & SWB_USETAB)) {
|
||||||
tabpage_T *tp;
|
FOR_ALL_TAB_WINDOWS(tp, wp) {
|
||||||
win_T *wp;
|
|
||||||
|
|
||||||
FOR_ALL_TAB_WINDOWS(tp, wp)
|
|
||||||
{
|
|
||||||
if (wp->w_buffer->b_fnum == qf_ptr->qf_fnum) {
|
if (wp->w_buffer->b_fnum == qf_ptr->qf_fnum) {
|
||||||
goto_tabpage_win(tp, wp);
|
goto_tabpage_win(tp, wp);
|
||||||
usable_win = true;
|
usable_win = true;
|
||||||
@@ -2236,12 +2232,11 @@ static win_T *qf_find_win(qf_info_T *qi)
|
|||||||
*/
|
*/
|
||||||
static buf_T *qf_find_buf(qf_info_T *qi)
|
static buf_T *qf_find_buf(qf_info_T *qi)
|
||||||
{
|
{
|
||||||
tabpage_T *tp;
|
FOR_ALL_TAB_WINDOWS(tp, win) {
|
||||||
win_T *win;
|
if (is_qf_win(win, qi)) {
|
||||||
|
|
||||||
FOR_ALL_TAB_WINDOWS(tp, win)
|
|
||||||
if (is_qf_win(win, qi))
|
|
||||||
return win->w_buffer;
|
return win->w_buffer;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@@ -6263,7 +6263,6 @@ int screen_valid(int doclear)
|
|||||||
void screenalloc(bool doclear)
|
void screenalloc(bool doclear)
|
||||||
{
|
{
|
||||||
int new_row, old_row;
|
int new_row, old_row;
|
||||||
win_T *wp;
|
|
||||||
int outofmem = FALSE;
|
int outofmem = FALSE;
|
||||||
int len;
|
int len;
|
||||||
schar_T *new_ScreenLines;
|
schar_T *new_ScreenLines;
|
||||||
@@ -6275,7 +6274,6 @@ void screenalloc(bool doclear)
|
|||||||
unsigned *new_LineOffset;
|
unsigned *new_LineOffset;
|
||||||
char_u *new_LineWraps;
|
char_u *new_LineWraps;
|
||||||
short *new_TabPageIdxs;
|
short *new_TabPageIdxs;
|
||||||
tabpage_T *tp;
|
|
||||||
static int entered = FALSE; /* avoid recursiveness */
|
static int entered = FALSE; /* avoid recursiveness */
|
||||||
static int done_outofmem_msg = FALSE; /* did outofmem message */
|
static int done_outofmem_msg = FALSE; /* did outofmem message */
|
||||||
int retry_count = 0;
|
int retry_count = 0;
|
||||||
@@ -6328,8 +6326,9 @@ retry:
|
|||||||
* Continuing with the old ScreenLines may result in a crash, because the
|
* Continuing with the old ScreenLines may result in a crash, because the
|
||||||
* size is wrong.
|
* size is wrong.
|
||||||
*/
|
*/
|
||||||
FOR_ALL_TAB_WINDOWS(tp, wp)
|
FOR_ALL_TAB_WINDOWS(tp, wp) {
|
||||||
win_free_lsize(wp);
|
win_free_lsize(wp);
|
||||||
|
}
|
||||||
if (aucmd_win != NULL)
|
if (aucmd_win != NULL)
|
||||||
win_free_lsize(aucmd_win);
|
win_free_lsize(aucmd_win);
|
||||||
|
|
||||||
@@ -6349,8 +6348,7 @@ retry:
|
|||||||
new_LineWraps = xmalloc((size_t)(Rows * sizeof(char_u)));
|
new_LineWraps = xmalloc((size_t)(Rows * sizeof(char_u)));
|
||||||
new_TabPageIdxs = xmalloc((size_t)(Columns * sizeof(short)));
|
new_TabPageIdxs = xmalloc((size_t)(Columns * sizeof(short)));
|
||||||
|
|
||||||
FOR_ALL_TAB_WINDOWS(tp, wp)
|
FOR_ALL_TAB_WINDOWS(tp, wp) {
|
||||||
{
|
|
||||||
win_alloc_lines(wp);
|
win_alloc_lines(wp);
|
||||||
}
|
}
|
||||||
if (aucmd_win != NULL && aucmd_win->w_lines == NULL) {
|
if (aucmd_win != NULL && aucmd_win->w_lines == NULL) {
|
||||||
|
@@ -1674,13 +1674,12 @@ close_windows (
|
|||||||
int keep_curwin /* don't close "curwin" */
|
int keep_curwin /* don't close "curwin" */
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
win_T *wp;
|
|
||||||
tabpage_T *tp, *nexttp;
|
tabpage_T *tp, *nexttp;
|
||||||
int h = tabline_height();
|
int h = tabline_height();
|
||||||
|
|
||||||
++RedrawingDisabled;
|
++RedrawingDisabled;
|
||||||
|
|
||||||
for (wp = firstwin; wp != NULL && lastwin != firstwin; ) {
|
for (win_T *wp = firstwin; wp != NULL && lastwin != firstwin; ) {
|
||||||
if (wp->w_buffer == buf && (!keep_curwin || wp != curwin)
|
if (wp->w_buffer == buf && (!keep_curwin || wp != curwin)
|
||||||
&& !(wp->w_closing || wp->w_buffer->b_closing)
|
&& !(wp->w_closing || wp->w_buffer->b_closing)
|
||||||
) {
|
) {
|
||||||
@@ -1695,8 +1694,8 @@ close_windows (
|
|||||||
/* Also check windows in other tab pages. */
|
/* Also check windows in other tab pages. */
|
||||||
for (tp = first_tabpage; tp != NULL; tp = nexttp) {
|
for (tp = first_tabpage; tp != NULL; tp = nexttp) {
|
||||||
nexttp = tp->tp_next;
|
nexttp = tp->tp_next;
|
||||||
if (tp != curtab)
|
if (tp != curtab) {
|
||||||
for (wp = tp->tp_firstwin; wp != NULL; wp = wp->w_next)
|
FOR_ALL_WINDOWS_IN_TAB(wp, tp) {
|
||||||
if (wp->w_buffer == buf
|
if (wp->w_buffer == buf
|
||||||
&& !(wp->w_closing || wp->w_buffer->b_closing)
|
&& !(wp->w_closing || wp->w_buffer->b_closing)
|
||||||
) {
|
) {
|
||||||
@@ -1708,6 +1707,8 @@ close_windows (
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
--RedrawingDisabled;
|
--RedrawingDisabled;
|
||||||
|
|
||||||
@@ -1963,7 +1964,6 @@ int win_close(win_T *win, int free_buf)
|
|||||||
*/
|
*/
|
||||||
void win_close_othertab(win_T *win, int free_buf, tabpage_T *tp)
|
void win_close_othertab(win_T *win, int free_buf, tabpage_T *tp)
|
||||||
{
|
{
|
||||||
win_T *wp;
|
|
||||||
int dir;
|
int dir;
|
||||||
tabpage_T *ptp = NULL;
|
tabpage_T *ptp = NULL;
|
||||||
int free_tp = FALSE;
|
int free_tp = FALSE;
|
||||||
@@ -1982,10 +1982,18 @@ void win_close_othertab(win_T *win, int free_buf, tabpage_T *tp)
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
/* Autocommands may have closed the window already. */
|
/* Autocommands may have closed the window already. */
|
||||||
for (wp = tp->tp_firstwin; wp != NULL && wp != win; wp = wp->w_next)
|
{
|
||||||
;
|
bool found_window = false;
|
||||||
if (wp == NULL)
|
FOR_ALL_WINDOWS_IN_TAB(wp, tp) {
|
||||||
|
if (wp == win) {
|
||||||
|
found_window = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!found_window) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* When closing the last window in a tab page remove the tab page. */
|
/* When closing the last window in a tab page remove the tab page. */
|
||||||
if (tp->tp_firstwin == tp->tp_lastwin) {
|
if (tp->tp_firstwin == tp->tp_lastwin) {
|
||||||
@@ -3285,14 +3293,11 @@ void win_goto(win_T *wp)
|
|||||||
*/
|
*/
|
||||||
tabpage_T *win_find_tabpage(win_T *win)
|
tabpage_T *win_find_tabpage(win_T *win)
|
||||||
{
|
{
|
||||||
win_T *wp;
|
FOR_ALL_TAB_WINDOWS(tp, wp) {
|
||||||
tabpage_T *tp;
|
if (wp == win) {
|
||||||
|
|
||||||
for (tp = first_tabpage; tp != NULL; tp = tp->tp_next)
|
|
||||||
for (wp = (tp == curtab ? firstwin : tp->tp_firstwin);
|
|
||||||
wp != NULL; wp = wp->w_next)
|
|
||||||
if (wp == win)
|
|
||||||
return tp;
|
return tp;
|
||||||
|
}
|
||||||
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3549,28 +3554,36 @@ win_T *buf_jump_open_win(buf_T *buf)
|
|||||||
*/
|
*/
|
||||||
win_T *buf_jump_open_tab(buf_T *buf)
|
win_T *buf_jump_open_tab(buf_T *buf)
|
||||||
{
|
{
|
||||||
win_T *wp;
|
|
||||||
|
|
||||||
/* First try the current tab page. */
|
// First try the current tab page.
|
||||||
wp = buf_jump_open_win(buf);
|
{
|
||||||
|
win_T *wp = buf_jump_open_win(buf);
|
||||||
if (wp != NULL)
|
if (wp != NULL)
|
||||||
return wp;
|
return wp;
|
||||||
|
}
|
||||||
|
|
||||||
FOR_ALL_TABS(tp) {
|
FOR_ALL_TABS(tp) {
|
||||||
|
// Skip the current tab since we already checked it.
|
||||||
if (tp != curtab) {
|
if (tp != curtab) {
|
||||||
for (wp = tp->tp_firstwin; wp != NULL; wp = wp->w_next)
|
FOR_ALL_WINDOWS_IN_TAB(wp, tp) {
|
||||||
if (wp->w_buffer == buf)
|
if (wp->w_buffer == buf) {
|
||||||
break;
|
|
||||||
if (wp != NULL) {
|
|
||||||
goto_tabpage_win(tp, wp);
|
goto_tabpage_win(tp, wp);
|
||||||
if (curwin != wp)
|
|
||||||
wp = NULL; /* something went wrong */
|
// If we the current window didn't switch,
|
||||||
break;
|
// something went wrong.
|
||||||
|
if (curwin != wp) {
|
||||||
|
wp = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Return the window we switched to.
|
||||||
|
return wp;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return wp;
|
// If we made it this far, we didn't find the buffer.
|
||||||
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -5011,17 +5024,16 @@ int only_one_window(void)
|
|||||||
*/
|
*/
|
||||||
void check_lnums(int do_curwin)
|
void check_lnums(int do_curwin)
|
||||||
{
|
{
|
||||||
win_T *wp;
|
FOR_ALL_TAB_WINDOWS(tp, wp) {
|
||||||
|
|
||||||
tabpage_T *tp;
|
|
||||||
|
|
||||||
FOR_ALL_TAB_WINDOWS(tp, wp)
|
|
||||||
if ((do_curwin || wp != curwin) && wp->w_buffer == curbuf) {
|
if ((do_curwin || wp != curwin) && wp->w_buffer == curbuf) {
|
||||||
if (wp->w_cursor.lnum > curbuf->b_ml.ml_line_count)
|
if (wp->w_cursor.lnum > curbuf->b_ml.ml_line_count) {
|
||||||
wp->w_cursor.lnum = curbuf->b_ml.ml_line_count;
|
wp->w_cursor.lnum = curbuf->b_ml.ml_line_count;
|
||||||
if (wp->w_topline > curbuf->b_ml.ml_line_count)
|
}
|
||||||
|
if (wp->w_topline > curbuf->b_ml.ml_line_count) {
|
||||||
wp->w_topline = curbuf->b_ml.ml_line_count;
|
wp->w_topline = curbuf->b_ml.ml_line_count;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user