Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set completions from the async thread #2563

Merged
merged 1 commit into from
Dec 3, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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