API: Implement buffer updates

Originally written by @phodge in
https://github.com/neovim/neovim/pull/5269.
This commit is contained in:
Peter Hodge
2018-01-26 20:36:11 +01:00
committed by KillTheMule
parent 418abfc9d0
commit edcc73e766
14 changed files with 371 additions and 49 deletions

View File

@@ -73,6 +73,7 @@
#include "nvim/os/os.h"
#include "nvim/os/time.h"
#include "nvim/os/input.h"
#include "nvim/liveupdate.h"
typedef enum {
kBLSUnchanged = 0,
@@ -574,6 +575,9 @@ void close_buffer(win_T *win, buf_T *buf, int action, int abort_if_last)
/* Change directories when the 'acd' option is set. */
do_autochdir();
// disable live updates for the current buffer
liveupdate_unregister_all(buf);
/*
* Remove the buffer from the list.
*/
@@ -784,6 +788,8 @@ free_buffer_stuff (
map_clear_int(buf, MAP_ALL_MODES, true, true); // clear local abbrevs
xfree(buf->b_start_fenc);
buf->b_start_fenc = NULL;
liveupdate_unregister_all(buf);
}
/*
@@ -1735,6 +1741,8 @@ buf_T * buflist_new(char_u *ffname, char_u *sfname, linenr_T lnum, int flags)
clrallmarks(buf); /* clear marks */
fmarks_check_names(buf); /* check file marks for this file */
buf->b_p_bl = (flags & BLN_LISTED) ? TRUE : FALSE; /* init 'buflisted' */
kv_destroy(buf->liveupdate_channels);
kv_init(buf->liveupdate_channels);
if (!(flags & BLN_DUMMY)) {
// Tricky: these autocommands may change the buffer list. They could also
// split the window with re-using the one empty buffer. This may result in