aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnatolii Sakhnik <sakhnik@gmail.com>2018-12-09 19:26:12 +0200
committerAnatolii Sakhnik <sakhnik@gmail.com>2018-12-09 19:45:56 +0200
commit2c92a4d0c8a398c8a7dfd1666fdcfd2ab89cc887 (patch)
treec5f56dcfd5e4a4f7fa383da90b0e3c9e6dac5c64
parentb7f2c7dd1d2a5753962c9276df3db8bc5d358b3e (diff)
downloadrneovim-2c92a4d0c8a398c8a7dfd1666fdcfd2ab89cc887.tar.gz
rneovim-2c92a4d0c8a398c8a7dfd1666fdcfd2ab89cc887.tar.bz2
rneovim-2c92a4d0c8a398c8a7dfd1666fdcfd2ab89cc887.zip
vim-patch:8.1.0397: no event triggered after updating diffs
Problem: No event triggered after updating diffs. Solution: Add the DiffUpdated event. https://github.com/vim/vim/commit/e8fa05b5bc2d6d76bf5af50176a63655d00d1110
-rw-r--r--runtime/doc/autocmd.txt5
-rw-r--r--src/nvim/auevents.lua1
-rw-r--r--src/nvim/diff.c2
-rw-r--r--src/nvim/testdir/test_diffmode.vim6
4 files changed, 14 insertions, 0 deletions
diff --git a/runtime/doc/autocmd.txt b/runtime/doc/autocmd.txt
index 4702656c41..c34dbaaf60 100644
--- a/runtime/doc/autocmd.txt
+++ b/runtime/doc/autocmd.txt
@@ -628,6 +628,11 @@ CursorMoved After the cursor was moved in Normal or Visual
CursorMovedI After the cursor was moved in Insert mode.
Not triggered when the popup menu is visible.
Otherwise the same as CursorMoved.
+ *DiffUpdated*
+DiffUpdated After diffs have been updated. Depending on
+ what kind of diff is being used (internal or
+ external) this can be triggered on every
+ change or when doing |:diffupdate|.
*DirChanged*
DirChanged After the |current-directory| was changed.
Sets these |v:event| keys:
diff --git a/src/nvim/auevents.lua b/src/nvim/auevents.lua
index a6290aaac1..ab92e84799 100644
--- a/src/nvim/auevents.lua
+++ b/src/nvim/auevents.lua
@@ -33,6 +33,7 @@ return {
'CursorHoldI', -- idem, in Insert mode
'CursorMoved', -- cursor was moved
'CursorMovedI', -- cursor was moved in Insert mode
+ 'DiffUpdated', -- diffs have been updated
'DirChanged', -- directory changed
'EncodingChanged', -- after changing the 'encoding' option
'ExitPre', -- before exiting
diff --git a/src/nvim/diff.c b/src/nvim/diff.c
index bd66b32213..0fb8324546 100644
--- a/src/nvim/diff.c
+++ b/src/nvim/diff.c
@@ -924,6 +924,8 @@ void ex_diffupdate(exarg_T *eap)
curwin->w_valid_cursor.lnum = 0;
diff_redraw(true);
+
+ apply_autocmds(EVENT_DIFFUPDATED, NULL, NULL, false, curbuf);
}
///
diff --git a/src/nvim/testdir/test_diffmode.vim b/src/nvim/testdir/test_diffmode.vim
index 645a87848b..6f25179ab1 100644
--- a/src/nvim/testdir/test_diffmode.vim
+++ b/src/nvim/testdir/test_diffmode.vim
@@ -2,6 +2,9 @@
func Test_diff_fold_sync()
enew!
+ let g:update_count = 0
+ au DiffUpdated * let g:update_count += 1
+
let l = range(50)
call setline(1, l)
diffthis
@@ -27,6 +30,9 @@ func Test_diff_fold_sync()
call win_gotoid(winone)
call assert_equal(23, getcurpos()[1])
+ call assert_equal(1, g:update_count)
+ au! DiffUpdated
+
windo diffoff
close!
set nomodified