aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLewis Russell <lewis6991@gmail.com>2022-12-14 15:00:48 +0000
committerGitHub <noreply@github.com>2022-12-14 15:00:48 +0000
commitd127c684faa9a112575798a81c87babb1c83a7ea (patch)
tree6c0080bff13ac6fd803f6141df7ac0d49c9af49e /src
parent090048bec9f80c46a6ce6ff05a419b15bc4bf028 (diff)
downloadrneovim-d127c684faa9a112575798a81c87babb1c83a7ea.tar.gz
rneovim-d127c684faa9a112575798a81c87babb1c83a7ea.tar.bz2
rneovim-d127c684faa9a112575798a81c87babb1c83a7ea.zip
fix(treesitter): properly restore `'syntax'` (#21358)
Diffstat (limited to 'src')
-rw-r--r--src/nvim/buffer_updates.c9
-rw-r--r--src/nvim/memory.c6
2 files changed, 15 insertions, 0 deletions
diff --git a/src/nvim/buffer_updates.c b/src/nvim/buffer_updates.c
index 2c92fb26b2..c66571560a 100644
--- a/src/nvim/buffer_updates.c
+++ b/src/nvim/buffer_updates.c
@@ -147,6 +147,15 @@ void buf_updates_unregister(buf_T *buf, uint64_t channelid)
}
}
+void buf_free_callbacks(buf_T *buf)
+{
+ kv_destroy(buf->update_channels);
+ for (size_t i = 0; i < kv_size(buf->update_callbacks); i++) {
+ buffer_update_callbacks_free(kv_A(buf->update_callbacks, i));
+ }
+ kv_destroy(buf->update_callbacks);
+}
+
void buf_updates_unload(buf_T *buf, bool can_reload)
{
size_t size = kv_size(buf->update_channels);
diff --git a/src/nvim/memory.c b/src/nvim/memory.c
index 8bc871344c..f1771b2fe2 100644
--- a/src/nvim/memory.c
+++ b/src/nvim/memory.c
@@ -14,6 +14,7 @@
#include "nvim/api/extmark.h"
#include "nvim/arglist.h"
#include "nvim/ascii.h"
+#include "nvim/buffer_updates.h"
#include "nvim/context.h"
#include "nvim/decoration_provider.h"
#include "nvim/eval.h"
@@ -812,6 +813,11 @@ void free_all_mem(void)
bufref_T bufref;
set_bufref(&bufref, buf);
nextbuf = buf->b_next;
+
+ // Since options (in addition to other stuff) have been freed above we need to ensure no
+ // callbacks are called, so free them before closing the buffer.
+ buf_free_callbacks(buf);
+
close_buffer(NULL, buf, DOBUF_WIPE, false, false);
// Didn't work, try next one.
buf = bufref_valid(&bufref) ? nextbuf : firstbuf;