From d96acdde480e00234bc4e5bee59df9ac740cb863 Mon Sep 17 00:00:00 2001 From: Camillo Schenone Date: Sat, 2 Dec 2023 22:18:54 +0100 Subject: [PATCH] fix: made the detaching of buffers on view close a sync function, to keep a reference to the window. Former-commit-id: 69d58868687fb402232b97eb90de223161292ca3 --- plugin.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/plugin.py b/plugin.py index b259af7..1eb62ed 100644 --- a/plugin.py +++ b/plugin.py @@ -384,10 +384,11 @@ class CodempClientViewEventListener(sublime_plugin.ViewEventListener): print("view {} deactivated".format(self.view.id())) safe_listener_detach(_txt_change_listener) - def on_close(self): + def on_pre_close(self): global _client buffer = get_buffer_from_buffer_id(self.view.buffer_id()) - sublime_asyncio.dispatch(buffer.detach(_client)) + # have to run the detach logic in sync, to keep a valid reference to the view. + sublime_asyncio.sync(buffer.detach(_client)) class CodempClientTextChangeListener(sublime_plugin.TextChangeListener):