mirror of
https://github.com/vim/vim.git
synced 2025-09-26 04:04:07 -04:00
updated for version 7.3.480
Problem: When using ":qa" and there is a changed buffer picking the buffer to jump to is not very good. Solution: Consider current and other tab pages. (Hirohito Higashi)
This commit is contained in:
@@ -1569,6 +1569,26 @@ can_abandon(buf, forceit)
|
|||||||
|| forceit);
|
|| forceit);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void add_bufnum __ARGS((int *bufnrs, int *bufnump, int nr));
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Add a buffer number to "bufnrs", unless it's already there.
|
||||||
|
*/
|
||||||
|
static void
|
||||||
|
add_bufnum(bufnrs, bufnump, nr)
|
||||||
|
int *bufnrs;
|
||||||
|
int *bufnump;
|
||||||
|
int nr;
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
|
for (i = 0; i < *bufnump; ++i)
|
||||||
|
if (bufnrs[i] == nr)
|
||||||
|
return;
|
||||||
|
bufnrs[*bufnump] = nr;
|
||||||
|
*bufnump = *bufnump + 1;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Return TRUE if any buffer was changed and cannot be abandoned.
|
* Return TRUE if any buffer was changed and cannot be abandoned.
|
||||||
* That changed buffer becomes the current buffer.
|
* That changed buffer becomes the current buffer.
|
||||||
@@ -1577,32 +1597,64 @@ can_abandon(buf, forceit)
|
|||||||
check_changed_any(hidden)
|
check_changed_any(hidden)
|
||||||
int hidden; /* Only check hidden buffers */
|
int hidden; /* Only check hidden buffers */
|
||||||
{
|
{
|
||||||
|
int ret = FALSE;
|
||||||
buf_T *buf;
|
buf_T *buf;
|
||||||
int save;
|
int save;
|
||||||
|
int i;
|
||||||
|
int bufnum = 0;
|
||||||
|
int bufcount = 0;
|
||||||
|
int *bufnrs;
|
||||||
#ifdef FEAT_WINDOWS
|
#ifdef FEAT_WINDOWS
|
||||||
|
tabpage_T *tp;
|
||||||
win_T *wp;
|
win_T *wp;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
for (;;)
|
|
||||||
{
|
|
||||||
/* check curbuf first: if it was changed we can't abandon it */
|
|
||||||
if (!hidden && curbufIsChanged())
|
|
||||||
buf = curbuf;
|
|
||||||
else
|
|
||||||
{
|
|
||||||
for (buf = firstbuf; buf != NULL; buf = buf->b_next)
|
for (buf = firstbuf; buf != NULL; buf = buf->b_next)
|
||||||
if ((!hidden || buf->b_nwindows == 0) && bufIsChanged(buf))
|
++bufcount;
|
||||||
break;
|
|
||||||
}
|
if (bufcount == 0)
|
||||||
if (buf == NULL) /* No buffers changed */
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
|
bufnrs = (int *)alloc(sizeof(int) * bufcount);
|
||||||
|
if (bufnrs == NULL)
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
/* curbuf */
|
||||||
|
bufnrs[bufnum++] = curbuf->b_fnum;
|
||||||
|
#ifdef FEAT_WINDOWS
|
||||||
|
/* buf in curtab */
|
||||||
|
FOR_ALL_WINDOWS(wp)
|
||||||
|
if (wp->w_buffer != curbuf)
|
||||||
|
add_bufnum(bufnrs, &bufnum, wp->w_buffer->b_fnum);
|
||||||
|
|
||||||
|
/* buf in other tab */
|
||||||
|
for (tp = first_tabpage; tp != NULL; tp = tp->tp_next)
|
||||||
|
if (tp != curtab)
|
||||||
|
for (wp = tp->tp_firstwin; wp != NULL; wp = wp->w_next)
|
||||||
|
add_bufnum(bufnrs, &bufnum, wp->w_buffer->b_fnum);
|
||||||
|
#endif
|
||||||
|
/* any other buf */
|
||||||
|
for (buf = firstbuf; buf != NULL; buf = buf->b_next)
|
||||||
|
add_bufnum(bufnrs, &bufnum, buf->b_fnum);
|
||||||
|
|
||||||
|
for (i = 0; i < bufnum; ++i)
|
||||||
|
{
|
||||||
|
buf = buflist_findnr(bufnrs[i]);
|
||||||
|
if (buf == NULL)
|
||||||
|
continue;
|
||||||
|
if ((!hidden || buf->b_nwindows == 0) && bufIsChanged(buf))
|
||||||
|
{
|
||||||
/* Try auto-writing the buffer. If this fails but the buffer no
|
/* Try auto-writing the buffer. If this fails but the buffer no
|
||||||
* longer exists it's not changed, that's OK. */
|
* longer exists it's not changed, that's OK. */
|
||||||
if (check_changed(buf, p_awa, TRUE, FALSE, TRUE) && buf_valid(buf))
|
if (check_changed(buf, p_awa, TRUE, FALSE, TRUE) && buf_valid(buf))
|
||||||
break; /* didn't save - still changes */
|
break; /* didn't save - still changes */
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (i >= bufnum)
|
||||||
|
goto theend;
|
||||||
|
|
||||||
|
ret = TRUE;
|
||||||
exiting = FALSE;
|
exiting = FALSE;
|
||||||
#if defined(FEAT_GUI_DIALOG) || defined(FEAT_CON_DIALOG)
|
#if defined(FEAT_GUI_DIALOG) || defined(FEAT_CON_DIALOG)
|
||||||
/*
|
/*
|
||||||
@@ -1635,24 +1687,29 @@ check_changed_any(hidden)
|
|||||||
#ifdef FEAT_WINDOWS
|
#ifdef FEAT_WINDOWS
|
||||||
/* Try to find a window that contains the buffer. */
|
/* Try to find a window that contains the buffer. */
|
||||||
if (buf != curbuf)
|
if (buf != curbuf)
|
||||||
for (wp = firstwin; wp != NULL; wp = wp->w_next)
|
FOR_ALL_TAB_WINDOWS(tp, wp)
|
||||||
if (wp->w_buffer == buf)
|
if (wp->w_buffer == buf)
|
||||||
{
|
{
|
||||||
win_goto(wp);
|
goto_tabpage_win(tp, wp);
|
||||||
# ifdef FEAT_AUTOCMD
|
# ifdef FEAT_AUTOCMD
|
||||||
/* Paranoia: did autocms wipe out the buffer with changes? */
|
/* Paranoia: did autocms wipe out the buffer with changes? */
|
||||||
if (!buf_valid(buf))
|
if (!buf_valid(buf))
|
||||||
return TRUE;
|
{
|
||||||
# endif
|
goto theend;
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
# endif
|
||||||
|
goto buf_found;
|
||||||
|
}
|
||||||
|
buf_found:
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Open the changed buffer in the current window. */
|
/* Open the changed buffer in the current window. */
|
||||||
if (buf != curbuf)
|
if (buf != curbuf)
|
||||||
set_curbuf(buf, DOBUF_GOTO);
|
set_curbuf(buf, DOBUF_GOTO);
|
||||||
|
|
||||||
return TRUE;
|
theend:
|
||||||
|
vim_free(bufnrs);
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@@ -714,6 +714,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 */
|
||||||
|
/**/
|
||||||
|
480,
|
||||||
/**/
|
/**/
|
||||||
479,
|
479,
|
||||||
/**/
|
/**/
|
||||||
|
Reference in New Issue
Block a user