Bram,
On Sa, 12 Mai 2012, Christian Brabandt wrote:
> > I think it's better than, instead of adding a ! to :diffupdate, that
> > command would always check the timestamp on the files involved. Like
> > using ":checktime N" on the buffers involved. That is probably what
> > most users expect to happen and prompts the user what to do about files
> > changed externally.
>
> Hmm, I started using buf_check_timestamp(), and it prompts to reload the
> buffer. But once you didn't reload the buffer, the next time you
> checked, it wouldn't prompt again.
here is an updated patch, using buf_check_timestamp() this time. Which
should prompt everytime, :diffupdat! has been called (even when the
prompt was only acknowledged the last time, but the buffer not
reloaded).
regards,
Christian
--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
diff --git a/runtime/doc/diff.txt b/runtime/doc/diff.txt
--- a/runtime/doc/diff.txt
+++ b/runtime/doc/diff.txt
@@ -178,7 +178,7 @@
nodiff" before hiding it.
*:diffu* *:diffupdate*
-:diffu[pdate] Update the diff highlighting and folds.
+:diffu[pdate][!] Update the diff highlighting and folds.
Vim attempts to keep the differences updated when you make changes to the
text. This mostly takes care of inserted and deleted lines. Changes within a
@@ -187,6 +187,9 @@
:diffupdate
+If the ! has been used, Vim will reread the files from disk before updating
+the diff. Be careful, you'll lose all changes you have made to the buffer, that
+have not yet been written to disk.
Vim will show filler lines for lines that are missing in one window but are
present in another. These lines were inserted in another file or deleted in
diff --git a/src/diff.c b/src/diff.c
--- a/src/diff.c
+++ b/src/diff.c
@@ -783,6 +783,23 @@
goto theend;
}
+ /* :diffupdate! */
+ if (eap!=NULL && eap->forceit)
+ {
+ for (idx_new = idx_orig; idx_new < DB_COUNT; ++idx_new)
+ {
+ buf = curtab->tp_diffbuf[idx_new];
+ if (buf_valid(buf))
+ {
+ long mtime = buf->b_mtime;
+ buf_check_timestamp(buf, FALSE);
+ /* hack to make sure buf_check_timestamp() triggers
+ * again next time when :diffupdate! is called */
+ buf->b_mtime = mtime;
+ }
+ }
+ }
+
/* Write the first buffer to a tempfile. */
buf = curtab->tp_diffbuf[idx_orig];
if (diff_write(buf, tmp_orig) == FAIL)
diff --git a/src/ex_cmds.h b/src/ex_cmds.h
--- a/src/ex_cmds.h
+++ b/src/ex_cmds.h
@@ -304,7 +304,7 @@
EX(CMD_display, "display", ex_display,
EXTRA|NOTRLCOM|TRLBAR|SBOXOK|CMDWIN),
EX(CMD_diffupdate, "diffupdate", ex_diffupdate,
- TRLBAR),
+ BANG|TRLBAR),
EX(CMD_diffget, "diffget", ex_diffgetput,
RANGE|EXTRA|TRLBAR|MODIFY),
EX(CMD_diffoff, "diffoff", ex_diffoff,