mirror of
https://github.com/vim/vim.git
synced 2025-09-24 03:44:06 -04:00
updated for version 7.4.082
Problem: Using "gf" in a changed buffer suggests adding "!", which is not possible. (Tim Chase) Solution: Pass a flag to check_changed() wether adding ! make sense.
This commit is contained in:
@@ -3253,8 +3253,10 @@ do_ecmd(fnum, ffname, sfname, eap, newlnum, flags, oldwin)
|
|||||||
if ( ((!other_file && !(flags & ECMD_OLDBUF))
|
if ( ((!other_file && !(flags & ECMD_OLDBUF))
|
||||||
|| (curbuf->b_nwindows == 1
|
|| (curbuf->b_nwindows == 1
|
||||||
&& !(flags & (ECMD_HIDE | ECMD_ADDBUF))))
|
&& !(flags & (ECMD_HIDE | ECMD_ADDBUF))))
|
||||||
&& check_changed(curbuf, p_awa, !other_file,
|
&& check_changed(curbuf, (p_awa ? CCGD_AW : 0)
|
||||||
(flags & ECMD_FORCEIT), FALSE))
|
| (other_file ? 0 : CCGD_MULTWIN)
|
||||||
|
| ((flags & ECMD_FORCEIT) ? CCGD_FORCEIT : 0)
|
||||||
|
| (eap == NULL ? 0 : CCGD_EXCMD)))
|
||||||
{
|
{
|
||||||
if (fnum == 0 && other_file && ffname != NULL)
|
if (fnum == 0 && other_file && ffname != NULL)
|
||||||
(void)setaltfname(ffname, sfname, newlnum < 0 ? 0 : newlnum);
|
(void)setaltfname(ffname, sfname, newlnum < 0 ? 0 : newlnum);
|
||||||
@@ -7664,7 +7666,7 @@ ex_drop(eap)
|
|||||||
# ifdef FEAT_WINDOWS
|
# ifdef FEAT_WINDOWS
|
||||||
++emsg_off;
|
++emsg_off;
|
||||||
# endif
|
# endif
|
||||||
split = check_changed(curbuf, TRUE, FALSE, FALSE, FALSE);
|
split = check_changed(curbuf, CCGD_AW | CCGD_EXCMD);
|
||||||
# ifdef FEAT_WINDOWS
|
# ifdef FEAT_WINDOWS
|
||||||
--emsg_off;
|
--emsg_off;
|
||||||
# else
|
# else
|
||||||
|
@@ -1436,20 +1436,20 @@ autowrite_all()
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* return TRUE if buffer was changed and cannot be abandoned.
|
* Return TRUE if buffer was changed and cannot be abandoned.
|
||||||
|
* For flags use the CCGD_ values.
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
check_changed(buf, checkaw, mult_win, forceit, allbuf)
|
check_changed(buf, flags)
|
||||||
buf_T *buf;
|
buf_T *buf;
|
||||||
int checkaw; /* do autowrite if buffer was changed */
|
int flags;
|
||||||
int mult_win; /* check also when several wins for the buf */
|
|
||||||
int forceit;
|
|
||||||
int allbuf UNUSED; /* may write all buffers */
|
|
||||||
{
|
{
|
||||||
|
int forceit = (flags & CCGD_FORCEIT);
|
||||||
|
|
||||||
if ( !forceit
|
if ( !forceit
|
||||||
&& bufIsChanged(buf)
|
&& bufIsChanged(buf)
|
||||||
&& (mult_win || buf->b_nwindows <= 1)
|
&& ((flags & CCGD_MULTWIN) || buf->b_nwindows <= 1)
|
||||||
&& (!checkaw || autowrite(buf, forceit) == FAIL))
|
&& (!(flags & CCGD_AW) || autowrite(buf, forceit) == FAIL))
|
||||||
{
|
{
|
||||||
#if defined(FEAT_GUI_DIALOG) || defined(FEAT_CON_DIALOG)
|
#if defined(FEAT_GUI_DIALOG) || defined(FEAT_CON_DIALOG)
|
||||||
if ((p_confirm || cmdmod.confirm) && p_write)
|
if ((p_confirm || cmdmod.confirm) && p_write)
|
||||||
@@ -1457,7 +1457,7 @@ check_changed(buf, checkaw, mult_win, forceit, allbuf)
|
|||||||
buf_T *buf2;
|
buf_T *buf2;
|
||||||
int count = 0;
|
int count = 0;
|
||||||
|
|
||||||
if (allbuf)
|
if (flags & CCGD_ALLBUF)
|
||||||
for (buf2 = firstbuf; buf2 != NULL; buf2 = buf2->b_next)
|
for (buf2 = firstbuf; buf2 != NULL; buf2 = buf2->b_next)
|
||||||
if (bufIsChanged(buf2)
|
if (bufIsChanged(buf2)
|
||||||
&& (buf2->b_ffname != NULL
|
&& (buf2->b_ffname != NULL
|
||||||
@@ -1480,7 +1480,10 @@ check_changed(buf, checkaw, mult_win, forceit, allbuf)
|
|||||||
return bufIsChanged(buf);
|
return bufIsChanged(buf);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
EMSG(_(e_nowrtmsg));
|
if (flags & CCGD_EXCMD)
|
||||||
|
EMSG(_(e_nowrtmsg));
|
||||||
|
else
|
||||||
|
EMSG(_(e_nowrtmsg_nobang));
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
return FALSE;
|
return FALSE;
|
||||||
@@ -1690,7 +1693,9 @@ check_changed_any(hidden)
|
|||||||
{
|
{
|
||||||
/* 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 ? CCGD_AW : 0)
|
||||||
|
| CCGD_MULTWIN
|
||||||
|
| CCGD_ALLBUF) && buf_valid(buf))
|
||||||
break; /* didn't save - still changes */
|
break; /* didn't save - still changes */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2274,7 +2279,10 @@ do_argfile(eap, argn)
|
|||||||
vim_free(p);
|
vim_free(p);
|
||||||
}
|
}
|
||||||
if ((!P_HID(curbuf) || !other)
|
if ((!P_HID(curbuf) || !other)
|
||||||
&& check_changed(curbuf, TRUE, !other, eap->forceit, FALSE))
|
&& check_changed(curbuf, CCGD_AW
|
||||||
|
| (other ? 0 : CCGD_MULTWIN)
|
||||||
|
| (eap->forceit ? CCGD_FORCEIT : 0)
|
||||||
|
| CCGD_EXCMD))
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2315,7 +2323,9 @@ ex_next(eap)
|
|||||||
*/
|
*/
|
||||||
if ( P_HID(curbuf)
|
if ( P_HID(curbuf)
|
||||||
|| eap->cmdidx == CMD_snext
|
|| eap->cmdidx == CMD_snext
|
||||||
|| !check_changed(curbuf, TRUE, FALSE, eap->forceit, FALSE))
|
|| !check_changed(curbuf, CCGD_AW
|
||||||
|
| (eap->forceit ? CCGD_FORCEIT : 0)
|
||||||
|
| CCGD_EXCMD))
|
||||||
{
|
{
|
||||||
if (*eap->arg != NUL) /* redefine file list */
|
if (*eap->arg != NUL) /* redefine file list */
|
||||||
{
|
{
|
||||||
@@ -2458,7 +2468,9 @@ ex_listdo(eap)
|
|||||||
if (eap->cmdidx == CMD_windo
|
if (eap->cmdidx == CMD_windo
|
||||||
|| eap->cmdidx == CMD_tabdo
|
|| eap->cmdidx == CMD_tabdo
|
||||||
|| P_HID(curbuf)
|
|| P_HID(curbuf)
|
||||||
|| !check_changed(curbuf, TRUE, FALSE, eap->forceit, FALSE))
|
|| !check_changed(curbuf, CCGD_AW
|
||||||
|
| (eap->forceit ? CCGD_FORCEIT : 0)
|
||||||
|
| CCGD_EXCMD))
|
||||||
{
|
{
|
||||||
/* start at the first argument/window/buffer */
|
/* start at the first argument/window/buffer */
|
||||||
i = 0;
|
i = 0;
|
||||||
|
@@ -6565,7 +6565,9 @@ ex_quit(eap)
|
|||||||
if (check_more(FALSE, eap->forceit) == OK && only_one_window())
|
if (check_more(FALSE, eap->forceit) == OK && only_one_window())
|
||||||
exiting = TRUE;
|
exiting = TRUE;
|
||||||
if ((!P_HID(curbuf)
|
if ((!P_HID(curbuf)
|
||||||
&& check_changed(curbuf, p_awa, FALSE, eap->forceit, FALSE))
|
&& check_changed(curbuf, (p_awa ? CCGD_AW : 0)
|
||||||
|
| (eap->forceit ? CCGD_FORCEIT : 0)
|
||||||
|
| CCGD_EXCMD))
|
||||||
|| check_more(TRUE, eap->forceit) == FAIL
|
|| check_more(TRUE, eap->forceit) == FAIL
|
||||||
|| (only_one_window() && check_changed_any(eap->forceit)))
|
|| (only_one_window() && check_changed_any(eap->forceit)))
|
||||||
{
|
{
|
||||||
@@ -7099,7 +7101,7 @@ handle_drop(filec, filev, split)
|
|||||||
if (!P_HID(curbuf) && !split)
|
if (!P_HID(curbuf) && !split)
|
||||||
{
|
{
|
||||||
++emsg_off;
|
++emsg_off;
|
||||||
split = check_changed(curbuf, TRUE, FALSE, FALSE, FALSE);
|
split = check_changed(curbuf, CCGD_AW);
|
||||||
--emsg_off;
|
--emsg_off;
|
||||||
}
|
}
|
||||||
if (split)
|
if (split)
|
||||||
@@ -7361,7 +7363,11 @@ ex_recover(eap)
|
|||||||
{
|
{
|
||||||
/* Set recoverymode right away to avoid the ATTENTION prompt. */
|
/* Set recoverymode right away to avoid the ATTENTION prompt. */
|
||||||
recoverymode = TRUE;
|
recoverymode = TRUE;
|
||||||
if (!check_changed(curbuf, p_awa, TRUE, eap->forceit, FALSE)
|
if (!check_changed(curbuf, (p_awa ? CCGD_AW : 0)
|
||||||
|
| CCGD_MULTWIN
|
||||||
|
| (eap->forceit ? CCGD_FORCEIT : 0)
|
||||||
|
| CCGD_EXCMD)
|
||||||
|
|
||||||
&& (*eap->arg == NUL
|
&& (*eap->arg == NUL
|
||||||
|| setfname(curbuf, eap->arg, NULL, TRUE) == OK))
|
|| setfname(curbuf, eap->arg, NULL, TRUE) == OK))
|
||||||
ml_recover();
|
ml_recover();
|
||||||
|
@@ -1490,6 +1490,7 @@ EXTERN char_u e_notmp[] INIT(= N_("E483: Can't get temp file name"));
|
|||||||
EXTERN char_u e_notopen[] INIT(= N_("E484: Can't open file %s"));
|
EXTERN char_u e_notopen[] INIT(= N_("E484: Can't open file %s"));
|
||||||
EXTERN char_u e_notread[] INIT(= N_("E485: Can't read file %s"));
|
EXTERN char_u e_notread[] INIT(= N_("E485: Can't read file %s"));
|
||||||
EXTERN char_u e_nowrtmsg[] INIT(= N_("E37: No write since last change (add ! to override)"));
|
EXTERN char_u e_nowrtmsg[] INIT(= N_("E37: No write since last change (add ! to override)"));
|
||||||
|
EXTERN char_u e_nowrtmsg_nobang[] INIT(= N_("E37: No write since last change"));
|
||||||
EXTERN char_u e_null[] INIT(= N_("E38: Null argument"));
|
EXTERN char_u e_null[] INIT(= N_("E38: Null argument"));
|
||||||
#ifdef FEAT_DIGRAPHS
|
#ifdef FEAT_DIGRAPHS
|
||||||
EXTERN char_u e_number_exp[] INIT(= N_("E39: Number expected"));
|
EXTERN char_u e_number_exp[] INIT(= N_("E39: Number expected"));
|
||||||
|
@@ -35,7 +35,7 @@ void prof_inchar_exit __ARGS((void));
|
|||||||
int prof_def_func __ARGS((void));
|
int prof_def_func __ARGS((void));
|
||||||
int autowrite __ARGS((buf_T *buf, int forceit));
|
int autowrite __ARGS((buf_T *buf, int forceit));
|
||||||
void autowrite_all __ARGS((void));
|
void autowrite_all __ARGS((void));
|
||||||
int check_changed __ARGS((buf_T *buf, int checkaw, int mult_win, int forceit, int allbuf));
|
int check_changed __ARGS((buf_T *buf, int flags));
|
||||||
void browse_save_fname __ARGS((buf_T *buf));
|
void browse_save_fname __ARGS((buf_T *buf));
|
||||||
void dialog_changed __ARGS((buf_T *buf, int checkall));
|
void dialog_changed __ARGS((buf_T *buf, int checkall));
|
||||||
int can_abandon __ARGS((buf_T *buf, int forceit));
|
int can_abandon __ARGS((buf_T *buf, int forceit));
|
||||||
|
@@ -738,6 +738,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 */
|
||||||
|
/**/
|
||||||
|
82,
|
||||||
/**/
|
/**/
|
||||||
81,
|
81,
|
||||||
/**/
|
/**/
|
||||||
|
@@ -1175,6 +1175,15 @@ extern char *(*dyn_libintl_textdomain)(const char *domainname);
|
|||||||
#define RESIZE_HOR 2 /* resize horizontally */
|
#define RESIZE_HOR 2 /* resize horizontally */
|
||||||
#define RESIZE_BOTH 15 /* resize in both directions */
|
#define RESIZE_BOTH 15 /* resize in both directions */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* flags for check_changed()
|
||||||
|
*/
|
||||||
|
#define CCGD_AW 1 /* do autowrite if buffer was changed */
|
||||||
|
#define CCGD_MULTWIN 2 /* check also when several wins for the buf */
|
||||||
|
#define CCGD_FORCEIT 4 /* ! used */
|
||||||
|
#define CCGD_ALLBUF 8 /* may write all buffers */
|
||||||
|
#define CCGD_EXCMD 16 /* may suggest using ! */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* "flags" values for option-setting functions.
|
* "flags" values for option-setting functions.
|
||||||
* When OPT_GLOBAL and OPT_LOCAL are both missing, set both local and global
|
* When OPT_GLOBAL and OPT_LOCAL are both missing, set both local and global
|
||||||
|
Reference in New Issue
Block a user