Hi Bram and developers,
How to reproduce:
- Prepare following Vim script file named `test.vim`.
func Prepare_diffthis()
au DiffUpdated * echomsg expand("<afile>")
let bufnames = map(range(1,4), '"buf_" . v:val')
for bn in bufnames
let cmd = (bn[-1:] == "1") ? "edit" : "rightbelow vnew"
exec cmd bn
call setline(1, "Contents of " . bn)
endfor
endfunc
- Start vanilla Vim with the script above.
$ vim --clean -S test.vim
- Execute function
:call Prepare_diffthis()
- Perform `diffthis` for all windows.
:windo diffthis
Expected behavior (I think):
- DiffUpdated is triggered for all windows.
buf_1
buf_2
buf_3
buf_4
Actual behavior:
- DiffUpdated is not triggered for the first window. (Message `buf_1` is not
displayed)
buf_2
buf_3
buf_4
Continue to do the following command:
:windo diffoff
Expected behavior (I think):
- DiffUpdated is triggered for all windows.
buf_1
buf_2
buf_3
buf_4
Actual behavior:
- DiffUpdated is not triggered for the last window. (Message `buf_4` is not
displayed)
buf_1
buf_2
buf_3
A Patch attached.
Please check it.
There may be room for discussion about judgment conditions :)
--
Best regards,
Hirohito Higashi (h_east)
--
--
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
---
You received this message because you are subscribed to the Google Groups
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.
diff --git a/src/diff.c b/src/diff.c
index 336157c6d..ab9992eab 100644
--- a/src/diff.c
+++ b/src/diff.c
@@ -941,7 +941,7 @@ ex_diffupdate(exarg_T *eap) // "eap" can be NULL
theend:
// A redraw is needed if there were diffs and they were cleared, or there
// are diffs now, which means they got updated.
- if (had_diffs || curtab->tp_first_diff != NULL)
+ if (had_diffs || curtab->tp_first_diff != NULL || curwin->w_p_diff_saved)
{
diff_redraw(TRUE);
apply_autocmds(EVENT_DIFFUPDATED, NULL, NULL, FALSE, curbuf);
diff --git a/src/testdir/test_diffmode.vim b/src/testdir/test_diffmode.vim
index 5a3a6beee..5794fc4f0 100644
--- a/src/testdir/test_diffmode.vim
+++ b/src/testdir/test_diffmode.vim
@@ -32,7 +32,7 @@ func Test_diff_fold_sync()
call win_gotoid(winone)
call assert_equal(23, getcurpos()[1])
- call assert_equal(1, g:update_count)
+ call assert_equal(2, g:update_count)
au! DiffUpdated
windo diffoff
@@ -924,3 +924,23 @@ func Test_diff_of_diff()
call StopVimInTerminal(buf)
call delete('Xtest_diff_diff')
endfunc
+
+func Test_diff_diffupdated_target()
+ enew!
+ let g:update_target = []
+ au DiffUpdated * call add(g:update_target, expand("<afile>"))
+
+ let bufnames = map(range(1,4), '"buf_" . v:val')
+ for bn in bufnames
+ let cmd = (bn[-1:] == "1") ? "edit" : "rightbelow vnew"
+ exec cmd bn
+ call setline(1, "Contents of " . bn)
+ endfor
+ windo diffthis
+ call assert_equal(bufnames, g:update_target)
+
+ let g:update_target = []
+ windo diffoff
+ call assert_equal(bufnames, g:update_target)
+ au! DiffUpdated
+endfunc