0
0
mirror of https://github.com/vim/vim.git synced 2025-09-04 21:33:48 -04:00

patch 8.1.0397: no event triggered after updating diffs

Problem:    No event triggered after updating diffs.
Solution:   Add the DiffUpdated event.
This commit is contained in:
Bram Moolenaar 2018-09-16 15:48:06 +02:00
parent 42c63356d7
commit e8fa05b5bc
6 changed files with 114 additions and 97 deletions

View File

@ -656,6 +656,11 @@ FileChangedRO Before making the first change to a read-only
*E881* *E881*
If the number of lines changes saving for undo If the number of lines changes saving for undo
may fail and the change will be aborted. may fail and the change will be aborted.
*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*
DirChanged The working directory has changed in response DirChanged The working directory has changed in response
to the |:cd| or |:lcd| commands, or as a to the |:cd| or |:lcd| commands, or as a

View File

@ -942,6 +942,8 @@ ex_diffupdate(exarg_T *eap) // "eap" can be NULL
curwin->w_valid_cursor.lnum = 0; curwin->w_valid_cursor.lnum = 0;
diff_redraw(TRUE); diff_redraw(TRUE);
apply_autocmds(EVENT_DIFFUPDATED, NULL, NULL, FALSE, curbuf);
} }
/* /*

View File

@ -7761,6 +7761,7 @@ static struct event_name
{"CursorHoldI", EVENT_CURSORHOLDI}, {"CursorHoldI", EVENT_CURSORHOLDI},
{"CursorMoved", EVENT_CURSORMOVED}, {"CursorMoved", EVENT_CURSORMOVED},
{"CursorMovedI", EVENT_CURSORMOVEDI}, {"CursorMovedI", EVENT_CURSORMOVEDI},
{"DiffUpdated", EVENT_DIFFUPDATED},
{"DirChanged", EVENT_DIRCHANGED}, {"DirChanged", EVENT_DIRCHANGED},
{"EncodingChanged", EVENT_ENCODINGCHANGED}, {"EncodingChanged", EVENT_ENCODINGCHANGED},
{"ExitPre", EVENT_EXITPRE}, {"ExitPre", EVENT_EXITPRE},

View File

@ -4,6 +4,9 @@ source screendump.vim
func Test_diff_fold_sync() func Test_diff_fold_sync()
enew! enew!
let g:update_count = 0
au DiffUpdated * let g:update_count += 1
let l = range(50) let l = range(50)
call setline(1, l) call setline(1, l)
diffthis diffthis
@ -29,6 +32,9 @@ func Test_diff_fold_sync()
call win_gotoid(winone) call win_gotoid(winone)
call assert_equal(23, getcurpos()[1]) call assert_equal(23, getcurpos()[1])
call assert_equal(1, g:update_count)
au! DiffUpdated
windo diffoff windo diffoff
close! close!
set nomodified set nomodified

View File

@ -794,6 +794,8 @@ static char *(features[]) =
static int included_patches[] = static int included_patches[] =
{ /* Add new patch number below this line */ { /* Add new patch number below this line */
/**/
397,
/**/ /**/
396, 396,
/**/ /**/

195
src/vim.h
View File

@ -1251,104 +1251,105 @@ typedef struct {
*/ */
enum auto_event enum auto_event
{ {
EVENT_BUFADD = 0, /* after adding a buffer to the buffer list */ EVENT_BUFADD = 0, // after adding a buffer to the buffer list
EVENT_BUFDELETE, /* deleting a buffer from the buffer list */ EVENT_BUFDELETE, // deleting a buffer from the buffer list
EVENT_BUFENTER, /* after entering a buffer */ EVENT_BUFENTER, // after entering a buffer
EVENT_BUFFILEPOST, /* after renaming a buffer */ EVENT_BUFFILEPOST, // after renaming a buffer
EVENT_BUFFILEPRE, /* before renaming a buffer */ EVENT_BUFFILEPRE, // before renaming a buffer
EVENT_BUFHIDDEN, /* just after buffer becomes hidden */ EVENT_BUFHIDDEN, // just after buffer becomes hidden
EVENT_BUFLEAVE, /* before leaving a buffer */ EVENT_BUFLEAVE, // before leaving a buffer
EVENT_BUFNEW, /* after creating any buffer */ EVENT_BUFNEW, // after creating any buffer
EVENT_BUFNEWFILE, /* when creating a buffer for a new file */ EVENT_BUFNEWFILE, // when creating a buffer for a new file
EVENT_BUFREADCMD, /* read buffer using command */ EVENT_BUFREADCMD, // read buffer using command
EVENT_BUFREADPOST, /* after reading a buffer */ EVENT_BUFREADPOST, // after reading a buffer
EVENT_BUFREADPRE, /* before reading a buffer */ EVENT_BUFREADPRE, // before reading a buffer
EVENT_BUFUNLOAD, /* just before unloading a buffer */ EVENT_BUFUNLOAD, // just before unloading a buffer
EVENT_BUFWINENTER, /* after showing a buffer in a window */ EVENT_BUFWINENTER, // after showing a buffer in a window
EVENT_BUFWINLEAVE, /* just after buffer removed from window */ EVENT_BUFWINLEAVE, // just after buffer removed from window
EVENT_BUFWIPEOUT, /* just before really deleting a buffer */ EVENT_BUFWIPEOUT, // just before really deleting a buffer
EVENT_BUFWRITECMD, /* write buffer using command */ EVENT_BUFWRITECMD, // write buffer using command
EVENT_BUFWRITEPOST, /* after writing a buffer */ EVENT_BUFWRITEPOST, // after writing a buffer
EVENT_BUFWRITEPRE, /* before writing a buffer */ EVENT_BUFWRITEPRE, // before writing a buffer
EVENT_CMDLINECHANGED, /* command line was modified*/ EVENT_CMDLINECHANGED, // command line was modified*/
EVENT_CMDLINEENTER, /* after entering the command line */ EVENT_CMDLINEENTER, // after entering the command line
EVENT_CMDLINELEAVE, /* before leaving the command line */ EVENT_CMDLINELEAVE, // before leaving the command line
EVENT_CMDUNDEFINED, /* command undefined */ EVENT_CMDUNDEFINED, // command undefined
EVENT_CMDWINENTER, /* after entering the cmdline window */ EVENT_CMDWINENTER, // after entering the cmdline window
EVENT_CMDWINLEAVE, /* before leaving the cmdline window */ EVENT_CMDWINLEAVE, // before leaving the cmdline window
EVENT_COLORSCHEME, /* after loading a colorscheme */ EVENT_COLORSCHEME, // after loading a colorscheme
EVENT_COLORSCHEMEPRE, /* before loading a colorscheme */ EVENT_COLORSCHEMEPRE, // before loading a colorscheme
EVENT_COMPLETEDONE, /* after finishing insert complete */ EVENT_COMPLETEDONE, // after finishing insert complete
EVENT_CURSORHOLD, /* cursor in same position for a while */ EVENT_CURSORHOLD, // cursor in same position for a while
EVENT_CURSORHOLDI, /* idem, in Insert mode */ EVENT_CURSORHOLDI, // idem, in Insert mode
EVENT_CURSORMOVED, /* cursor was moved */ EVENT_CURSORMOVED, // cursor was moved
EVENT_CURSORMOVEDI, /* cursor was moved in Insert mode */ EVENT_CURSORMOVEDI, // cursor was moved in Insert mode
EVENT_DIRCHANGED, /* after user changed directory */ EVENT_DIFFUPDATED, // after diffs were updated
EVENT_ENCODINGCHANGED, /* after changing the 'encoding' option */ EVENT_DIRCHANGED, // after user changed directory
EVENT_EXITPRE, /* before exiting */ EVENT_ENCODINGCHANGED, // after changing the 'encoding' option
EVENT_FILEAPPENDCMD, /* append to a file using command */ EVENT_EXITPRE, // before exiting
EVENT_FILEAPPENDPOST, /* after appending to a file */ EVENT_FILEAPPENDCMD, // append to a file using command
EVENT_FILEAPPENDPRE, /* before appending to a file */ EVENT_FILEAPPENDPOST, // after appending to a file
EVENT_FILECHANGEDRO, /* before first change to read-only file */ EVENT_FILEAPPENDPRE, // before appending to a file
EVENT_FILECHANGEDSHELL, /* after shell command that changed file */ EVENT_FILECHANGEDRO, // before first change to read-only file
EVENT_FILECHANGEDSHELLPOST, /* after (not) reloading changed file */ EVENT_FILECHANGEDSHELL, // after shell command that changed file
EVENT_FILEREADCMD, /* read from a file using command */ EVENT_FILECHANGEDSHELLPOST, // after (not) reloading changed file
EVENT_FILEREADPOST, /* after reading a file */ EVENT_FILEREADCMD, // read from a file using command
EVENT_FILEREADPRE, /* before reading a file */ EVENT_FILEREADPOST, // after reading a file
EVENT_FILETYPE, /* new file type detected (user defined) */ EVENT_FILEREADPRE, // before reading a file
EVENT_FILEWRITECMD, /* write to a file using command */ EVENT_FILETYPE, // new file type detected (user defined)
EVENT_FILEWRITEPOST, /* after writing a file */ EVENT_FILEWRITECMD, // write to a file using command
EVENT_FILEWRITEPRE, /* before writing a file */ EVENT_FILEWRITEPOST, // after writing a file
EVENT_FILTERREADPOST, /* after reading from a filter */ EVENT_FILEWRITEPRE, // before writing a file
EVENT_FILTERREADPRE, /* before reading from a filter */ EVENT_FILTERREADPOST, // after reading from a filter
EVENT_FILTERWRITEPOST, /* after writing to a filter */ EVENT_FILTERREADPRE, // before reading from a filter
EVENT_FILTERWRITEPRE, /* before writing to a filter */ EVENT_FILTERWRITEPOST, // after writing to a filter
EVENT_FOCUSGAINED, /* got the focus */ EVENT_FILTERWRITEPRE, // before writing to a filter
EVENT_FOCUSLOST, /* lost the focus to another app */ EVENT_FOCUSGAINED, // got the focus
EVENT_FUNCUNDEFINED, /* if calling a function which doesn't exist */ EVENT_FOCUSLOST, // lost the focus to another app
EVENT_GUIENTER, /* after starting the GUI */ EVENT_FUNCUNDEFINED, // if calling a function which doesn't exist
EVENT_GUIFAILED, /* after starting the GUI failed */ EVENT_GUIENTER, // after starting the GUI
EVENT_INSERTCHANGE, /* when changing Insert/Replace mode */ EVENT_GUIFAILED, // after starting the GUI failed
EVENT_INSERTCHARPRE, /* before inserting a char */ EVENT_INSERTCHANGE, // when changing Insert/Replace mode
EVENT_INSERTENTER, /* when entering Insert mode */ EVENT_INSERTCHARPRE, // before inserting a char
EVENT_INSERTLEAVE, /* when leaving Insert mode */ EVENT_INSERTENTER, // when entering Insert mode
EVENT_MENUPOPUP, /* just before popup menu is displayed */ EVENT_INSERTLEAVE, // when leaving Insert mode
EVENT_OPTIONSET, /* option was set */ EVENT_MENUPOPUP, // just before popup menu is displayed
EVENT_QUICKFIXCMDPOST, /* after :make, :grep etc. */ EVENT_OPTIONSET, // option was set
EVENT_QUICKFIXCMDPRE, /* before :make, :grep etc. */ EVENT_QUICKFIXCMDPOST, // after :make, :grep etc.
EVENT_QUITPRE, /* before :quit */ EVENT_QUICKFIXCMDPRE, // before :make, :grep etc.
EVENT_REMOTEREPLY, /* upon string reception from a remote vim */ EVENT_QUITPRE, // before :quit
EVENT_SESSIONLOADPOST, /* after loading a session file */ EVENT_REMOTEREPLY, // upon string reception from a remote vim
EVENT_SHELLCMDPOST, /* after ":!cmd" */ EVENT_SESSIONLOADPOST, // after loading a session file
EVENT_SHELLFILTERPOST, /* after ":1,2!cmd", ":w !cmd", ":r !cmd". */ EVENT_SHELLCMDPOST, // after ":!cmd"
EVENT_SOURCECMD, /* sourcing a Vim script using command */ EVENT_SHELLFILTERPOST, // after ":1,2!cmd", ":w !cmd", ":r !cmd".
EVENT_SOURCEPRE, /* before sourcing a Vim script */ EVENT_SOURCECMD, // sourcing a Vim script using command
EVENT_SPELLFILEMISSING, /* spell file missing */ EVENT_SOURCEPRE, // before sourcing a Vim script
EVENT_STDINREADPOST, /* after reading from stdin */ EVENT_SPELLFILEMISSING, // spell file missing
EVENT_STDINREADPRE, /* before reading from stdin */ EVENT_STDINREADPOST, // after reading from stdin
EVENT_SWAPEXISTS, /* found existing swap file */ EVENT_STDINREADPRE, // before reading from stdin
EVENT_SYNTAX, /* syntax selected */ EVENT_SWAPEXISTS, // found existing swap file
EVENT_TABCLOSED, /* after closing a tab page */ EVENT_SYNTAX, // syntax selected
EVENT_TABENTER, /* after entering a tab page */ EVENT_TABCLOSED, // after closing a tab page
EVENT_TABLEAVE, /* before leaving a tab page */ EVENT_TABENTER, // after entering a tab page
EVENT_TABNEW, /* when entering a new tab page */ EVENT_TABLEAVE, // before leaving a tab page
EVENT_TERMCHANGED, /* after changing 'term' */ EVENT_TABNEW, // when entering a new tab page
EVENT_TERMINALOPEN, /* after a terminal buffer was created */ EVENT_TERMCHANGED, // after changing 'term'
EVENT_TERMRESPONSE, /* after setting "v:termresponse" */ EVENT_TERMINALOPEN, // after a terminal buffer was created
EVENT_TEXTCHANGED, /* text was modified not in Insert mode */ EVENT_TERMRESPONSE, // after setting "v:termresponse"
EVENT_TEXTCHANGEDI, /* text was modified in Insert mode */ EVENT_TEXTCHANGED, // text was modified not in Insert mode
EVENT_TEXTCHANGEDP, /* TextChangedI with popup menu visible */ EVENT_TEXTCHANGEDI, // text was modified in Insert mode
EVENT_TEXTYANKPOST, /* after some text was yanked */ EVENT_TEXTCHANGEDP, // TextChangedI with popup menu visible
EVENT_USER, /* user defined autocommand */ EVENT_TEXTYANKPOST, // after some text was yanked
EVENT_VIMENTER, /* after starting Vim */ EVENT_USER, // user defined autocommand
EVENT_VIMLEAVE, /* before exiting Vim */ EVENT_VIMENTER, // after starting Vim
EVENT_VIMLEAVEPRE, /* before exiting Vim and writing .viminfo */ EVENT_VIMLEAVE, // before exiting Vim
EVENT_VIMRESIZED, /* after Vim window was resized */ EVENT_VIMLEAVEPRE, // before exiting Vim and writing .viminfo
EVENT_WINENTER, /* after entering a window */ EVENT_VIMRESIZED, // after Vim window was resized
EVENT_WINLEAVE, /* before leaving a window */ EVENT_WINENTER, // after entering a window
EVENT_WINNEW, /* when entering a new window */ EVENT_WINLEAVE, // before leaving a window
EVENT_WINNEW, // when entering a new window
NUM_EVENTS /* MUST be the last one */ NUM_EVENTS // MUST be the last one
}; };
typedef enum auto_event event_T; typedef enum auto_event event_T;