From 9e30185f3d979921efbb1abbae45e1ea444b025d Mon Sep 17 00:00:00 2001 From: jwortmann Date: Tue, 3 Dec 2024 08:46:48 +0100 Subject: [PATCH] Set completions from the async thread (#2563) --- plugin/documents.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/plugin/documents.py b/plugin/documents.py index 2cb449ced..e0ada4784 100644 --- a/plugin/documents.py +++ b/plugin/documents.py @@ -7,6 +7,7 @@ from .core.constants import DOCUMENT_HIGHLIGHT_KIND_SCOPES from .core.constants import HOVER_ENABLED_KEY from .core.constants import RegionKey +from .core.constants import ST_VERSION from .core.logging import debug from .core.open import open_in_browser from .core.panels import PanelName @@ -618,8 +619,11 @@ def _on_query_completions_resolved_async( flags: sublime.AutoCompleteFlags = sublime.AutoCompleteFlags.NONE ) -> None: self._completions_task = None - # Resolve on the main thread to prevent any sort of data race for _set_target (see sublime_plugin.py). - sublime.set_timeout(lambda: clist.set_completions(completions, flags)) + if ST_VERSION >= 4184: # https://github.com/sublimehq/sublime_text/issues/6249#issuecomment-2502804237 + clist.set_completions(completions, flags) + else: + # Resolve on the main thread to prevent any sort of data race for _set_target (see sublime_plugin.py). + sublime.set_timeout(lambda: clist.set_completions(completions, flags)) # --- textDocument/signatureHelp -----------------------------------------------------------------------------------