On Fr, 11 Mai 2012, Christian Brabandt wrote:

> On Do, 10 Mai 2012, GeertVc wrote:
> 
> > When changing one or both files which are currently open/compared in
> > VimDiff, in an *external* editor (so, not in Vim or VimDiff itself),
> > VimDiff doesn't update the diffs when forcing an update using the
> > command ":diffupdate".  In fact, nothing happens at all while
> > executing this ":diffupdate" command.
> > 
> > Only when forcing VimDiff to lose focus and re-gain focus again, I see
> > the message that files have been changed.  After (re)loading the
> > changed files, the diff is updated.
> > 
> > I enforce losing focus by executing the command ":shell" from within
> > VimDiff and then exit-ing the shell mode again to come back to
> > VimDiff.
> > 
> > Is ":diffupdate" not supposed to "forcefully" rescan both files and
> > update the view?
> > 
> > I'm using VimDiff version 7.1.138 on Ubuntu 8.04, but the same
> > complaint is valid for VimDiff 7.3.449 on a very recent Ubuntu 12.04
> > distro.
> 
> Yeah, diffupdate only updates the diff for the buffer that is loaded. It 
> doesn't check, whether the original file, has been changed. If you want 
> this, I suggest you set the 'autoread' option together with an 
> CursorHold autocommand, e.g. like this
> 
> au CursorHold * checktime

BTW: Here is a patch, that let's you use :diffupdate! to force reloading 
the buffers before updating the diff. Be careful, as you will lose all 
your changes that you have made to a buffer without saving.

regards,
Christian

-- 
You received this message from the "vim_dev" 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,17 @@
 	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))
+	    buf_reload(buf, buf->b_orig_mode);
+	}
+    }
+
     /* 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,

Raspunde prin e-mail lui