0
0
mirror of https://github.com/vim/vim.git synced 2025-09-06 21:53:38 -04:00

updated for version 7.2-041

This commit is contained in:
Bram Moolenaar 2008-11-15 13:12:07 +00:00
parent 1c8603613a
commit 701f7afcdf
15 changed files with 107 additions and 37 deletions

View File

@ -33,7 +33,7 @@ static char_u *buflist_match __ARGS((regprog_T *prog, buf_T *buf));
static char_u *fname_match __ARGS((regprog_T *prog, char_u *name)); static char_u *fname_match __ARGS((regprog_T *prog, char_u *name));
#endif #endif
static void buflist_setfpos __ARGS((buf_T *buf, win_T *win, linenr_T lnum, colnr_T col, int copy_options)); static void buflist_setfpos __ARGS((buf_T *buf, win_T *win, linenr_T lnum, colnr_T col, int copy_options));
static wininfo_T *find_wininfo __ARGS((buf_T *buf)); static wininfo_T *find_wininfo __ARGS((buf_T *buf, int skip_diff_buffer));
#ifdef UNIX #ifdef UNIX
static buf_T *buflist_findname_stat __ARGS((char_u *ffname, struct stat *st)); static buf_T *buflist_findname_stat __ARGS((char_u *ffname, struct stat *st));
static int otherfile_buf __ARGS((buf_T *buf, char_u *ffname, struct stat *stp)); static int otherfile_buf __ARGS((buf_T *buf, char_u *ffname, struct stat *stp));
@ -1093,7 +1093,7 @@ do_buffer(action, start, dir, count, forceit)
#endif #endif
setpcmark(); setpcmark();
retval = do_ecmd(0, NULL, NULL, NULL, ECMD_ONE, retval = do_ecmd(0, NULL, NULL, NULL, ECMD_ONE,
forceit ? ECMD_FORCEIT : 0); forceit ? ECMD_FORCEIT : 0, curwin);
/* /*
* do_ecmd() may create a new buffer, then we have to delete * do_ecmd() may create a new buffer, then we have to delete
@ -1316,7 +1316,7 @@ set_curbuf(buf, action)
setpcmark(); setpcmark();
if (!cmdmod.keepalt) if (!cmdmod.keepalt)
curwin->w_alt_fnum = curbuf->b_fnum; /* remember alternate file */ curwin->w_alt_fnum = curbuf->b_fnum; /* remember alternate file */
buflist_altfpos(); /* remember curpos */ buflist_altfpos(curwin); /* remember curpos */
#ifdef FEAT_VISUAL #ifdef FEAT_VISUAL
/* Don't restart Select mode after switching to another buffer. */ /* Don't restart Select mode after switching to another buffer. */
@ -2404,22 +2404,70 @@ buflist_setfpos(buf, win, lnum, col, copy_options)
return; return;
} }
#ifdef FEAT_DIFF
static int wininfo_other_tab_diff __ARGS((wininfo_T *wip));
/*
* Return TRUE when "wip" has 'diff' set and the diff is only for another tab
* page. That's because a diff is local to a tab page.
*/
static int
wininfo_other_tab_diff(wip)
wininfo_T *wip;
{
win_T *wp;
if (wip->wi_opt.wo_diff)
{
for (wp = firstwin; wp != NULL; wp = wp->w_next)
/* return FALSE when it's a window in the current tab page, thus
* the buffer was in diff mode here */
if (wip->wi_win == wp)
return FALSE;
return TRUE;
}
return FALSE;
}
#endif
/* /*
* Find info for the current window in buffer "buf". * Find info for the current window in buffer "buf".
* If not found, return the info for the most recently used window. * If not found, return the info for the most recently used window.
* When "skip_diff_buffer" is TRUE avoid windows with 'diff' set that is in
* another tab page.
* Returns NULL when there isn't any info. * Returns NULL when there isn't any info.
*/ */
/*ARGSUSED*/
static wininfo_T * static wininfo_T *
find_wininfo(buf) find_wininfo(buf, skip_diff_buffer)
buf_T *buf; buf_T *buf;
int skip_diff_buffer;
{ {
wininfo_T *wip; wininfo_T *wip;
for (wip = buf->b_wininfo; wip != NULL; wip = wip->wi_next) for (wip = buf->b_wininfo; wip != NULL; wip = wip->wi_next)
if (wip->wi_win == curwin) if (wip->wi_win == curwin
#ifdef FEAT_DIFF
&& (!skip_diff_buffer || !wininfo_other_tab_diff(wip))
#endif
)
break; break;
if (wip == NULL) /* if no fpos for curwin, use the first in the list */
/* If no wininfo for curwin, use the first in the list (that doesn't have
* 'diff' set and is in another tab page). */
if (wip == NULL)
{
#ifdef FEAT_DIFF
if (skip_diff_buffer)
{
for (wip = buf->b_wininfo; wip != NULL; wip = wip->wi_next)
if (!wininfo_other_tab_diff(wip))
break;
}
else
#endif
wip = buf->b_wininfo; wip = buf->b_wininfo;
}
return wip; return wip;
} }
@ -2440,7 +2488,7 @@ get_winopts(buf)
clearFolding(curwin); clearFolding(curwin);
#endif #endif
wip = find_wininfo(buf); wip = find_wininfo(buf, TRUE);
if (wip != NULL && wip->wi_optset) if (wip != NULL && wip->wi_optset)
{ {
copy_winopt(&wip->wi_opt, &curwin->w_onebuf_opt); copy_winopt(&wip->wi_opt, &curwin->w_onebuf_opt);
@ -2472,7 +2520,7 @@ buflist_findfpos(buf)
wininfo_T *wip; wininfo_T *wip;
static pos_T no_position = {1, 0}; static pos_T no_position = {1, 0};
wip = find_wininfo(buf); wip = find_wininfo(buf, FALSE);
if (wip != NULL) if (wip != NULL)
return &(wip->wi_fpos); return &(wip->wi_fpos);
else else
@ -2793,14 +2841,14 @@ buflist_slash_adjust()
#endif #endif
/* /*
* Set alternate cursor position for current window. * Set alternate cursor position for the current buffer and window "win".
* Also save the local window option values. * Also save the local window option values.
*/ */
void void
buflist_altfpos() buflist_altfpos(win)
win_T *win;
{ {
buflist_setfpos(curbuf, curwin, curwin->w_cursor.lnum, buflist_setfpos(curbuf, win, win->w_cursor.lnum, win->w_cursor.col, TRUE);
curwin->w_cursor.col, TRUE);
} }
/* /*
@ -4492,7 +4540,7 @@ do_arg_all(count, forceit, keep_tabs)
ECMD_ONE, ECMD_ONE,
((P_HID(curwin->w_buffer) ((P_HID(curwin->w_buffer)
|| bufIsChanged(curwin->w_buffer)) ? ECMD_HIDE : 0) || bufIsChanged(curwin->w_buffer)) ? ECMD_HIDE : 0)
+ ECMD_OLDBUF); + ECMD_OLDBUF, curwin);
#ifdef FEAT_AUTOCMD #ifdef FEAT_AUTOCMD
if (use_firstwin) if (use_firstwin)
++autocmd_no_leave; ++autocmd_no_leave;

View File

@ -3052,7 +3052,8 @@ getfile(fnum, ffname, sfname, setpm, lnum, forceit)
retval = 0; /* it's in the same file */ retval = 0; /* it's in the same file */
} }
else if (do_ecmd(fnum, ffname, sfname, NULL, lnum, else if (do_ecmd(fnum, ffname, sfname, NULL, lnum,
(P_HID(curbuf) ? ECMD_HIDE : 0) + (forceit ? ECMD_FORCEIT : 0)) == OK) (P_HID(curbuf) ? ECMD_HIDE : 0) + (forceit ? ECMD_FORCEIT : 0),
curwin) == OK)
retval = -1; /* opened another file */ retval = -1; /* opened another file */
else else
retval = 1; /* error encountered */ retval = 1; /* error encountered */
@ -3085,17 +3086,21 @@ theend:
* ECMD_OLDBUF: use existing buffer if it exists * ECMD_OLDBUF: use existing buffer if it exists
* ECMD_FORCEIT: ! used for Ex command * ECMD_FORCEIT: ! used for Ex command
* ECMD_ADDBUF: don't edit, just add to buffer list * ECMD_ADDBUF: don't edit, just add to buffer list
* oldwin: Should be "curwin" when editing a new buffer in the current
* window, NULL when splitting the window first. When not NULL info
* of the previous buffer for "oldwin" is stored.
* *
* return FAIL for failure, OK otherwise * return FAIL for failure, OK otherwise
*/ */
int int
do_ecmd(fnum, ffname, sfname, eap, newlnum, flags) do_ecmd(fnum, ffname, sfname, eap, newlnum, flags, oldwin)
int fnum; int fnum;
char_u *ffname; char_u *ffname;
char_u *sfname; char_u *sfname;
exarg_T *eap; /* can be NULL! */ exarg_T *eap; /* can be NULL! */
linenr_T newlnum; linenr_T newlnum;
int flags; int flags;
win_T *oldwin;
{ {
int other_file; /* TRUE if editing another file */ int other_file; /* TRUE if editing another file */
int oldbuf; /* TRUE if using existing buffer */ int oldbuf; /* TRUE if using existing buffer */
@ -3267,7 +3272,8 @@ do_ecmd(fnum, ffname, sfname, eap, newlnum, flags)
{ {
if (!cmdmod.keepalt) if (!cmdmod.keepalt)
curwin->w_alt_fnum = curbuf->b_fnum; curwin->w_alt_fnum = curbuf->b_fnum;
buflist_altfpos(); if (oldwin != NULL)
buflist_altfpos(oldwin);
} }
if (fnum) if (fnum)
@ -3371,7 +3377,7 @@ do_ecmd(fnum, ffname, sfname, eap, newlnum, flags)
/* close the link to the current buffer */ /* close the link to the current buffer */
u_sync(FALSE); u_sync(FALSE);
close_buffer(curwin, curbuf, close_buffer(oldwin, curbuf,
(flags & ECMD_HIDE) ? 0 : DOBUF_UNLOAD); (flags & ECMD_HIDE) ? 0 : DOBUF_UNLOAD);
#ifdef FEAT_AUTOCMD #ifdef FEAT_AUTOCMD
@ -5609,7 +5615,13 @@ ex_help(eap)
*/ */
alt_fnum = curbuf->b_fnum; alt_fnum = curbuf->b_fnum;
(void)do_ecmd(0, NULL, NULL, NULL, ECMD_LASTL, (void)do_ecmd(0, NULL, NULL, NULL, ECMD_LASTL,
ECMD_HIDE + ECMD_SET_HELP); ECMD_HIDE + ECMD_SET_HELP,
#ifdef FEAT_WINDOWS
NULL /* buffer is still open, don't store info */
#else
curwin
#endif
);
if (!cmdmod.keepalt) if (!cmdmod.keepalt)
curwin->w_alt_fnum = alt_fnum; curwin->w_alt_fnum = alt_fnum;
empty_fnum = curbuf->b_fnum; empty_fnum = curbuf->b_fnum;

View File

@ -2132,8 +2132,8 @@ do_argfile(eap, argn)
* argument index. */ * argument index. */
if (do_ecmd(0, alist_name(&ARGLIST[curwin->w_arg_idx]), NULL, if (do_ecmd(0, alist_name(&ARGLIST[curwin->w_arg_idx]), NULL,
eap, ECMD_LAST, eap, ECMD_LAST,
(P_HID(curwin->w_buffer) ? ECMD_HIDE : 0) + (P_HID(curwin->w_buffer) ? ECMD_HIDE : 0)
(eap->forceit ? ECMD_FORCEIT : 0)) == FAIL) + (eap->forceit ? ECMD_FORCEIT : 0), curwin) == FAIL)
curwin->w_arg_idx = old_arg_idx; curwin->w_arg_idx = old_arg_idx;
/* like Vi: set the mark where the cursor is in the file. */ /* like Vi: set the mark where the cursor is in the file. */
else if (eap->cmdidx != CMD_argdo) else if (eap->cmdidx != CMD_argdo)

View File

@ -7488,7 +7488,8 @@ do_exedit(eap, old_curwin)
/* ":new" or ":tabnew" without argument: edit an new empty buffer */ /* ":new" or ":tabnew" without argument: edit an new empty buffer */
setpcmark(); setpcmark();
(void)do_ecmd(0, NULL, NULL, eap, ECMD_ONE, (void)do_ecmd(0, NULL, NULL, eap, ECMD_ONE,
ECMD_HIDE + (eap->forceit ? ECMD_FORCEIT : 0)); ECMD_HIDE + (eap->forceit ? ECMD_FORCEIT : 0),
old_curwin == NULL ? curwin : NULL);
} }
else if ((eap->cmdidx != CMD_split else if ((eap->cmdidx != CMD_split
#ifdef FEAT_VERTSPLIT #ifdef FEAT_VERTSPLIT
@ -7525,7 +7526,7 @@ do_exedit(eap, old_curwin)
#ifdef FEAT_LISTCMDS #ifdef FEAT_LISTCMDS
+ (eap->cmdidx == CMD_badd ? ECMD_ADDBUF : 0 ) + (eap->cmdidx == CMD_badd ? ECMD_ADDBUF : 0 )
#endif #endif
) == FAIL) , old_curwin == NULL ? curwin : NULL) == FAIL)
{ {
/* Editing the file failed. If the window was split, close it. */ /* Editing the file failed. If the window was split, close it. */
#ifdef FEAT_WINDOWS #ifdef FEAT_WINDOWS

View File

@ -6051,7 +6051,7 @@ ex_window()
cmdwin_type = '-'; cmdwin_type = '-';
/* Create the command-line buffer empty. */ /* Create the command-line buffer empty. */
(void)do_ecmd(0, NULL, NULL, NULL, ECMD_ONE, ECMD_HIDE); (void)do_ecmd(0, NULL, NULL, NULL, ECMD_ONE, ECMD_HIDE, NULL);
(void)setfname(curbuf, (char_u *)"[Command Line]", NULL, TRUE); (void)setfname(curbuf, (char_u *)"[Command Line]", NULL, TRUE);
set_option_value((char_u *)"bt", 0L, (char_u *)"nofile", OPT_LOCAL); set_option_value((char_u *)"bt", 0L, (char_u *)"nofile", OPT_LOCAL);
set_option_value((char_u *)"swf", 0L, NULL, OPT_LOCAL); set_option_value((char_u *)"swf", 0L, NULL, OPT_LOCAL);

View File

@ -1114,7 +1114,8 @@ vi_open_file(fname)
char *fname; char *fname;
{ {
++no_wait_return; ++no_wait_return;
do_ecmd(0, (char_u *)fname, NULL, NULL, ECMD_ONE, ECMD_HIDE+ECMD_OLDBUF); do_ecmd(0, (char_u *)fname, NULL, NULL, ECMD_ONE, ECMD_HIDE+ECMD_OLDBUF,
curwin);
curbuf->b_sniff = TRUE; curbuf->b_sniff = TRUE;
--no_wait_return; /* [ex_docmd.c] */ --no_wait_return; /* [ex_docmd.c] */
} }

View File

@ -2588,7 +2588,7 @@ edit_buffers(parmp)
# endif # endif
(void)do_ecmd(0, arg_idx < GARGCOUNT (void)do_ecmd(0, arg_idx < GARGCOUNT
? alist_name(&GARGLIST[arg_idx]) : NULL, ? alist_name(&GARGLIST[arg_idx]) : NULL,
NULL, NULL, ECMD_LASTL, ECMD_HIDE); NULL, NULL, ECMD_LASTL, ECMD_HIDE, curwin);
# ifdef HAS_SWAP_EXISTS_ACTION # ifdef HAS_SWAP_EXISTS_ACTION
if (swap_exists_did_quit) if (swap_exists_did_quit)
{ {

View File

@ -1795,7 +1795,7 @@ nb_do_cmd(
buf->displayname = NULL; buf->displayname = NULL;
netbeansReadFile = 0; /* don't try to open disk file */ netbeansReadFile = 0; /* don't try to open disk file */
do_ecmd(0, NULL, 0, 0, ECMD_ONE, ECMD_HIDE + ECMD_OLDBUF); do_ecmd(0, NULL, 0, 0, ECMD_ONE, ECMD_HIDE + ECMD_OLDBUF, curwin);
netbeansReadFile = 1; netbeansReadFile = 1;
buf->bufp = curbuf; buf->bufp = curbuf;
maketitle(); maketitle();
@ -1960,7 +1960,7 @@ nb_do_cmd(
netbeansReadFile = 0; /* don't try to open disk file */ netbeansReadFile = 0; /* don't try to open disk file */
do_ecmd(0, (char_u *)buf->displayname, 0, 0, ECMD_ONE, do_ecmd(0, (char_u *)buf->displayname, 0, 0, ECMD_ONE,
ECMD_HIDE + ECMD_OLDBUF); ECMD_HIDE + ECMD_OLDBUF, curwin);
netbeansReadFile = 1; netbeansReadFile = 1;
buf->bufp = curbuf; buf->bufp = curbuf;
maketitle(); maketitle();
@ -1979,7 +1979,7 @@ nb_do_cmd(
vim_free(buf->displayname); vim_free(buf->displayname);
buf->displayname = nb_unquote(args, NULL); buf->displayname = nb_unquote(args, NULL);
do_ecmd(0, (char_u *)buf->displayname, NULL, NULL, ECMD_ONE, do_ecmd(0, (char_u *)buf->displayname, NULL, NULL, ECMD_ONE,
ECMD_HIDE + ECMD_OLDBUF); ECMD_HIDE + ECMD_OLDBUF, curwin);
buf->bufp = curbuf; buf->bufp = curbuf;
buf->initDone = TRUE; buf->initDone = TRUE;
doupdate = 1; doupdate = 1;

View File

@ -6050,7 +6050,7 @@ nv_gotofile(cap)
autowrite(curbuf, FALSE); autowrite(curbuf, FALSE);
setpcmark(); setpcmark();
(void)do_ecmd(0, ptr, NULL, NULL, ECMD_LAST, (void)do_ecmd(0, ptr, NULL, NULL, ECMD_LAST,
P_HID(curbuf) ? ECMD_HIDE : 0); P_HID(curbuf) ? ECMD_HIDE : 0, curwin);
if (cap->nchar == 'F' && lnum >= 0) if (cap->nchar == 'F' && lnum >= 0)
{ {
curwin->w_cursor.lnum = lnum; curwin->w_cursor.lnum = lnum;

View File

@ -573,7 +573,7 @@ pum_set_selected(n, repeat)
{ {
/* Don't want to sync undo in the current buffer. */ /* Don't want to sync undo in the current buffer. */
++no_u_sync; ++no_u_sync;
res = do_ecmd(0, NULL, NULL, NULL, ECMD_ONE, 0); res = do_ecmd(0, NULL, NULL, NULL, ECMD_ONE, 0, NULL);
--no_u_sync; --no_u_sync;
if (res == OK) if (res == OK)
{ {

View File

@ -33,7 +33,7 @@ buf_T *setaltfname __ARGS((char_u *ffname, char_u *sfname, linenr_T lnum));
char_u *getaltfname __ARGS((int errmsg)); char_u *getaltfname __ARGS((int errmsg));
int buflist_add __ARGS((char_u *fname, int flags)); int buflist_add __ARGS((char_u *fname, int flags));
void buflist_slash_adjust __ARGS((void)); void buflist_slash_adjust __ARGS((void));
void buflist_altfpos __ARGS((void)); void buflist_altfpos __ARGS((win_T *win));
int otherfile __ARGS((char_u *ffname)); int otherfile __ARGS((char_u *ffname));
void buf_setino __ARGS((buf_T *buf)); void buf_setino __ARGS((buf_T *buf));
void fileinfo __ARGS((int fullname, int shorthelp, int dont_truncate)); void fileinfo __ARGS((int fullname, int shorthelp, int dont_truncate));

View File

@ -27,7 +27,7 @@ void ex_wnext __ARGS((exarg_T *eap));
void do_wqall __ARGS((exarg_T *eap)); void do_wqall __ARGS((exarg_T *eap));
int not_writing __ARGS((void)); int not_writing __ARGS((void));
int getfile __ARGS((int fnum, char_u *ffname, char_u *sfname, int setpm, linenr_T lnum, int forceit)); int getfile __ARGS((int fnum, char_u *ffname, char_u *sfname, int setpm, linenr_T lnum, int forceit));
int do_ecmd __ARGS((int fnum, char_u *ffname, char_u *sfname, exarg_T *eap, linenr_T newlnum, int flags)); int do_ecmd __ARGS((int fnum, char_u *ffname, char_u *sfname, exarg_T *eap, linenr_T newlnum, int flags, win_T *oldwin));
void ex_append __ARGS((exarg_T *eap)); void ex_append __ARGS((exarg_T *eap));
void ex_change __ARGS((exarg_T *eap)); void ex_change __ARGS((exarg_T *eap));
void ex_z __ARGS((exarg_T *eap)); void ex_z __ARGS((exarg_T *eap));

View File

@ -1420,6 +1420,7 @@ qf_jump(qi, dir, errornr, forceit)
win_T *win; win_T *win;
win_T *altwin; win_T *altwin;
#endif #endif
win_T *oldwin = curwin;
int print_message = TRUE; int print_message = TRUE;
int len; int len;
#ifdef FEAT_FOLDING #ifdef FEAT_FOLDING
@ -1744,7 +1745,8 @@ qf_jump(qi, dir, errornr, forceit)
} }
else else
ok = do_ecmd(qf_ptr->qf_fnum, NULL, NULL, NULL, (linenr_T)1, ok = do_ecmd(qf_ptr->qf_fnum, NULL, NULL, NULL, (linenr_T)1,
ECMD_HIDE + ECMD_SET_HELP); ECMD_HIDE + ECMD_SET_HELP,
oldwin == curwin ? curwin : NULL);
} }
else else
ok = buflist_getfile(qf_ptr->qf_fnum, ok = buflist_getfile(qf_ptr->qf_fnum,
@ -2267,6 +2269,7 @@ ex_copen(eap)
win_T *win; win_T *win;
tabpage_T *prevtab = curtab; tabpage_T *prevtab = curtab;
buf_T *qf_buf; buf_T *qf_buf;
win_T *oldwin = curwin;
if (eap->cmdidx == CMD_lopen || eap->cmdidx == CMD_lwindow) if (eap->cmdidx == CMD_lopen || eap->cmdidx == CMD_lwindow)
{ {
@ -2326,14 +2329,16 @@ ex_copen(eap)
win->w_llist->qf_refcount++; win->w_llist->qf_refcount++;
} }
if (oldwin != curwin)
oldwin = NULL; /* don't store info when in another window */
if (qf_buf != NULL) if (qf_buf != NULL)
/* Use the existing quickfix buffer */ /* Use the existing quickfix buffer */
(void)do_ecmd(qf_buf->b_fnum, NULL, NULL, NULL, ECMD_ONE, (void)do_ecmd(qf_buf->b_fnum, NULL, NULL, NULL, ECMD_ONE,
ECMD_HIDE + ECMD_OLDBUF); ECMD_HIDE + ECMD_OLDBUF, oldwin);
else else
{ {
/* Create a new quickfix buffer */ /* Create a new quickfix buffer */
(void)do_ecmd(0, NULL, NULL, NULL, ECMD_ONE, ECMD_HIDE); (void)do_ecmd(0, NULL, NULL, NULL, ECMD_ONE, ECMD_HIDE, oldwin);
/* switch off 'swapfile' */ /* switch off 'swapfile' */
set_option_value((char_u *)"swf", 0L, NULL, OPT_LOCAL); set_option_value((char_u *)"swf", 0L, NULL, OPT_LOCAL);
set_option_value((char_u *)"bt", 0L, (char_u *)"quickfix", set_option_value((char_u *)"bt", 0L, (char_u *)"quickfix",

View File

@ -676,6 +676,8 @@ static char *(features[]) =
static int included_patches[] = static int included_patches[] =
{ /* Add new patch number below this line */ { /* Add new patch number below this line */
/**/
41,
/**/ /**/
40, 40,
/**/ /**/

View File

@ -531,7 +531,8 @@ wingotofile:
# ifdef FEAT_SCROLLBIND # ifdef FEAT_SCROLLBIND
curwin->w_p_scb = FALSE; curwin->w_p_scb = FALSE;
# endif # endif
(void)do_ecmd(0, ptr, NULL, NULL, ECMD_LASTL, ECMD_HIDE); (void)do_ecmd(0, ptr, NULL, NULL, ECMD_LASTL,
ECMD_HIDE, NULL);
if (nchar == 'F' && lnum >= 0) if (nchar == 'F' && lnum >= 0)
{ {
curwin->w_cursor.lnum = lnum; curwin->w_cursor.lnum = lnum;