Skip to content

Commit

Permalink
Set completions from the async thread (#2563)
Browse files Browse the repository at this point in the history
  • Loading branch information
jwortmann authored Dec 3, 2024
1 parent 9be040d commit 9e30185
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions plugin/documents.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 -----------------------------------------------------------------------------------

Expand Down

0 comments on commit 9e30185

Please sign in to comment.