mirror of
https://github.com/vim/vim.git
synced 2025-09-29 04:34:16 -04:00
Do not write an undo file if there is nothing to undo.
This commit is contained in:
@@ -1093,9 +1093,6 @@ Vim 7.3:
|
|||||||
Use register_shell_extension()? (George Reilly, 2010 May 26)
|
Use register_shell_extension()? (George Reilly, 2010 May 26)
|
||||||
Ron's version: http://dev.ronware.org/p/vim/finfo?name=gvim.nsi
|
Ron's version: http://dev.ronware.org/p/vim/finfo?name=gvim.nsi
|
||||||
- Persistent undo bugs / fixes:
|
- Persistent undo bugs / fixes:
|
||||||
- Memory leak reproduced by Dominique Pelle, 2010 May 28.
|
|
||||||
- When there is no undo info (undolevels negative), delete the undo file.
|
|
||||||
Already done?
|
|
||||||
- Need to check all values for evil manipulation.
|
- Need to check all values for evil manipulation.
|
||||||
- Add undofile(name): get undo file name for buffer "name".
|
- Add undofile(name): get undo file name for buffer "name".
|
||||||
- patch for unused functions. (Dominique Pelle, 2010 May 29)
|
- patch for unused functions. (Dominique Pelle, 2010 May 29)
|
||||||
|
43
src/undo.c
43
src/undo.c
@@ -998,7 +998,12 @@ u_write_undo(name, forceit, buf, hash)
|
|||||||
if (file_name == NULL)
|
if (file_name == NULL)
|
||||||
{
|
{
|
||||||
if (p_verbose > 0)
|
if (p_verbose > 0)
|
||||||
smsg((char_u *)_("Cannot write undo file in any directory in 'undodir'"));
|
{
|
||||||
|
verbose_enter();
|
||||||
|
smsg((char_u *)
|
||||||
|
_("Cannot write undo file in any directory in 'undodir'"));
|
||||||
|
verbose_leave();
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1040,8 +1045,15 @@ u_write_undo(name, forceit, buf, hash)
|
|||||||
if (fd < 0)
|
if (fd < 0)
|
||||||
{
|
{
|
||||||
if (name != NULL || p_verbose > 0)
|
if (name != NULL || p_verbose > 0)
|
||||||
smsg((char_u *)_("Will not overwrite with undo file, cannot read: %s"),
|
{
|
||||||
|
if (name == NULL)
|
||||||
|
verbose_enter();
|
||||||
|
smsg((char_u *)
|
||||||
|
_("Will not overwrite with undo file, cannot read: %s"),
|
||||||
file_name);
|
file_name);
|
||||||
|
if (name == NULL)
|
||||||
|
verbose_leave();
|
||||||
|
}
|
||||||
goto theend;
|
goto theend;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -1055,8 +1067,14 @@ u_write_undo(name, forceit, buf, hash)
|
|||||||
|| memcmp(buf, UF_START_MAGIC, UF_START_MAGIC_LEN) != 0)
|
|| memcmp(buf, UF_START_MAGIC, UF_START_MAGIC_LEN) != 0)
|
||||||
{
|
{
|
||||||
if (name != NULL || p_verbose > 0)
|
if (name != NULL || p_verbose > 0)
|
||||||
|
{
|
||||||
|
if (name == NULL)
|
||||||
|
verbose_enter();
|
||||||
smsg((char_u *)_("Will not overwrite, this is not an undo file: %s"),
|
smsg((char_u *)_("Will not overwrite, this is not an undo file: %s"),
|
||||||
file_name);
|
file_name);
|
||||||
|
if (name == NULL)
|
||||||
|
verbose_leave();
|
||||||
|
}
|
||||||
goto theend;
|
goto theend;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1064,6 +1082,15 @@ u_write_undo(name, forceit, buf, hash)
|
|||||||
mch_remove(file_name);
|
mch_remove(file_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* If there is no undo information at all, quit here after deleting any
|
||||||
|
* existing undo file. */
|
||||||
|
if (buf->b_u_numhead == 0)
|
||||||
|
{
|
||||||
|
if (p_verbose > 0)
|
||||||
|
verb_msg((char_u *)_("Skipping undo file write, noting to undo"));
|
||||||
|
goto theend;
|
||||||
|
}
|
||||||
|
|
||||||
fd = mch_open((char *)file_name,
|
fd = mch_open((char *)file_name,
|
||||||
O_CREAT|O_EXTRA|O_WRONLY|O_EXCL|O_NOFOLLOW, perm);
|
O_CREAT|O_EXTRA|O_WRONLY|O_EXCL|O_NOFOLLOW, perm);
|
||||||
if (fd < 0)
|
if (fd < 0)
|
||||||
@@ -1073,10 +1100,14 @@ u_write_undo(name, forceit, buf, hash)
|
|||||||
}
|
}
|
||||||
(void)mch_setperm(file_name, perm);
|
(void)mch_setperm(file_name, perm);
|
||||||
if (p_verbose > 0)
|
if (p_verbose > 0)
|
||||||
|
{
|
||||||
|
verbose_enter();
|
||||||
smsg((char_u *)_("Writing undo file: %s"), file_name);
|
smsg((char_u *)_("Writing undo file: %s"), file_name);
|
||||||
|
verbose_leave();
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef U_DEBUG
|
#ifdef U_DEBUG
|
||||||
/* Check if there already is a problem before writing. */
|
/* Check there is no problem in undo info before writing. */
|
||||||
u_check(FALSE);
|
u_check(FALSE);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -1290,7 +1321,11 @@ u_read_undo(name, hash)
|
|||||||
file_name = name;
|
file_name = name;
|
||||||
|
|
||||||
if (p_verbose > 0)
|
if (p_verbose > 0)
|
||||||
|
{
|
||||||
|
verbose_enter();
|
||||||
smsg((char_u *)_("Reading undo file: %s"), file_name);
|
smsg((char_u *)_("Reading undo file: %s"), file_name);
|
||||||
|
verbose_leave();
|
||||||
|
}
|
||||||
fp = mch_fopen((char *)file_name, "r");
|
fp = mch_fopen((char *)file_name, "r");
|
||||||
if (fp == NULL)
|
if (fp == NULL)
|
||||||
{
|
{
|
||||||
@@ -1326,8 +1361,10 @@ u_read_undo(name, hash)
|
|||||||
{
|
{
|
||||||
if (p_verbose > 0 || name != NULL)
|
if (p_verbose > 0 || name != NULL)
|
||||||
{
|
{
|
||||||
|
if (name == NULL)
|
||||||
verbose_enter();
|
verbose_enter();
|
||||||
give_warning((char_u *)_("File contents changed, cannot use undo info"), TRUE);
|
give_warning((char_u *)_("File contents changed, cannot use undo info"), TRUE);
|
||||||
|
if (name == NULL)
|
||||||
verbose_leave();
|
verbose_leave();
|
||||||
}
|
}
|
||||||
goto error;
|
goto error;
|
||||||
|
Reference in New Issue
Block a user