0
0
mirror of https://github.com/vim/vim.git synced 2025-09-23 03:43:49 -04:00

Add the 'undoreload' option to be able to undo a file reload.

This commit is contained in:
Bram Moolenaar
2010-07-24 20:27:03 +02:00
parent 72ada0f8c2
commit 59f931ef54
16 changed files with 167 additions and 79 deletions

View File

@@ -3144,6 +3144,7 @@ do_ecmd(fnum, ffname, sfname, eap, newlnum, flags, oldwin)
#ifdef FEAT_SPELL
int did_get_winopts = FALSE;
#endif
int readfile_flags = 0;
if (eap != NULL)
command = eap->do_ecmd_cmd;
@@ -3570,7 +3571,22 @@ do_ecmd(fnum, ffname, sfname, eap, newlnum, flags, oldwin)
else
new_name = NULL;
#endif
buf_freeall(curbuf, FALSE, FALSE); /* free all things for buffer */
if (p_ur < 0 || curbuf->b_ml.ml_line_count <= p_ur)
{
/* Save all the text, so that the reload can be undone.
* Sync first so that this is a separate undo-able action. */
u_sync(FALSE);
if (u_savecommon(0, curbuf->b_ml.ml_line_count + 1, 0, TRUE)
== FAIL)
goto theend;
u_unchanged(curbuf);
buf_freeall(curbuf, BFA_KEEP_UNDO);
/* tell readfile() not to clear or reload undo info */
readfile_flags = READ_KEEP_UNDO;
}
else
buf_freeall(curbuf, 0); /* free all things for buffer */
#ifdef FEAT_AUTOCMD
/* If autocommands deleted the buffer we were going to re-edit, give
* up and jump to the end. */
@@ -3667,10 +3683,10 @@ do_ecmd(fnum, ffname, sfname, eap, newlnum, flags, oldwin)
* Open the buffer and read the file.
*/
#if defined(FEAT_AUTOCMD) && defined(FEAT_EVAL)
if (should_abort(open_buffer(FALSE, eap)))
if (should_abort(open_buffer(FALSE, eap, readfile_flags)))
retval = FAIL;
#else
(void)open_buffer(FALSE, eap);
(void)open_buffer(FALSE, eap, readfile_flags);
#endif
#if defined(HAS_SWAP_EXISTS_ACTION)