diff --git a/src/ex_cmds.h b/src/ex_cmds.h --- a/src/ex_cmds.h +++ b/src/ex_cmds.h @@ -788,7 +788,7 @@ EX(CMD_rubyfile, "rubyfile", ex_rubyfile, RANGE|FILE1|NEEDARG|CMDWIN), EX(CMD_rundo, "rundo", ex_rundo, - NEEDARG|EXTRA|XFILE), + BANG|NEEDARG|EXTRA|XFILE), EX(CMD_rviminfo, "rviminfo", ex_viminfo, BANG|FILE1|TRLBAR|CMDWIN), EX(CMD_substitute, "substitute", do_sub, diff --git a/src/ex_docmd.c b/src/ex_docmd.c --- a/src/ex_docmd.c +++ b/src/ex_docmd.c @@ -8551,7 +8551,7 @@ char_u hash[UNDO_HASH_SIZE]; u_compute_hash(hash); - u_read_undo(eap->arg, hash, NULL); + u_read_undo(eap->arg, hash, NULL, eap->forceit); } #endif diff --git a/src/fileio.c b/src/fileio.c --- a/src/fileio.c +++ b/src/fileio.c @@ -2616,7 +2616,7 @@ char_u hash[UNDO_HASH_SIZE]; sha256_finish(&sha_ctx, hash); - u_read_undo(NULL, hash, fname); + u_read_undo(NULL, hash, fname, FALSE); } #endif diff --git a/src/proto/undo.pro b/src/proto/undo.pro --- a/src/proto/undo.pro +++ b/src/proto/undo.pro @@ -9,7 +9,7 @@ void u_compute_hash __ARGS((char_u *hash)); char_u *u_get_undo_file_name __ARGS((char_u *buf_ffname, int reading)); void u_write_undo __ARGS((char_u *name, int forceit, buf_T *buf, char_u *hash)); -void u_read_undo __ARGS((char_u *name, char_u *hash, char_u *orig_name)); +void u_read_undo __ARGS((char_u *name, char_u *hash, char_u *orig_name, int force)); void u_undo __ARGS((int count)); void u_redo __ARGS((int count)); void undo_time __ARGS((long step, int sec, int file, int absolute)); diff --git a/src/undo.c b/src/undo.c --- a/src/undo.c +++ b/src/undo.c @@ -1555,10 +1555,11 @@ * "hash[UNDO_HASH_SIZE]" must be the hash value of the buffer text. */ void -u_read_undo(name, hash, orig_name) +u_read_undo(name, hash, orig_name, force) char_u *name; char_u *hash; char_u *orig_name; + int force; /* :rundo! */ { char_u *file_name; FILE *fp; @@ -1675,8 +1676,9 @@ goto error; } line_count = (linenr_T)get4c(fp); - if (memcmp(hash, read_hash, UNDO_HASH_SIZE) != 0 + if ((memcmp(hash, read_hash, UNDO_HASH_SIZE) != 0 || line_count != curbuf->b_ml.ml_line_count) + && !force) { if (p_verbose > 0 || name != NULL) {