From edcc73e766438facc88db19000f054aa52ab8b13 Mon Sep 17 00:00:00 2001 From: Peter Hodge Date: Fri, 26 Jan 2018 20:36:11 +0100 Subject: API: Implement buffer updates Originally written by @phodge in https://github.com/neovim/neovim/pull/5269. --- src/nvim/buffer.c | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'src/nvim/buffer.c') diff --git a/src/nvim/buffer.c b/src/nvim/buffer.c index ba63822837..124e479686 100644 --- a/src/nvim/buffer.c +++ b/src/nvim/buffer.c @@ -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 -- cgit