From 315016f0b4397f2d812e984883a2f889ebf35f7b Mon Sep 17 00:00:00 2001 From: Rafal Chlodnicki Date: Wed, 30 Oct 2024 21:07:49 +0100 Subject: [PATCH] fix: use user-preferred flags when canceling completions --- plugin/completion.py | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/plugin/completion.py b/plugin/completion.py index 6d2e5fdcd..6e4292900 100644 --- a/plugin/completion.py +++ b/plugin/completion.py @@ -212,12 +212,7 @@ def _resolve_completions_async(self, responses: list[ResolvedCompletions]) -> No items: list[sublime.CompletionItem] = [] item_defaults: CompletionItemDefaults = {} errors: list[Error] = [] - flags = sublime.AutoCompleteFlags.NONE - prefs = userprefs() - if prefs.inhibit_snippet_completions: - flags |= sublime.AutoCompleteFlags.INHIBIT_EXPLICIT_COMPLETIONS - if prefs.inhibit_word_completions: - flags |= sublime.AutoCompleteFlags.INHIBIT_WORD_COMPLETIONS + flags = self._get_userpref_flags() view_settings = self._view.settings() include_snippets = view_settings.get("auto_complete_include_snippets") and \ (self._triggered_manually or view_settings.get("auto_complete_include_snippets_when_typing")) @@ -253,7 +248,7 @@ def _resolve_completions_async(self, responses: list[ResolvedCompletions]) -> No self._resolve_task_async(items, flags) def cancel_async(self) -> None: - self._resolve_task_async([]) + self._resolve_task_async([], self._get_userpref_flags()) self._cancel_pending_requests_async() def _cancel_pending_requests_async(self) -> None: @@ -272,6 +267,15 @@ def _resolve_task_async( self._resolved = True self._on_done_async(completions, flags) + def _get_userpref_flags(self) -> sublime.AutoCompleteFlags: + prefs = userprefs() + flags = sublime.AutoCompleteFlags.NONE + if prefs.inhibit_snippet_completions: + flags |= sublime.AutoCompleteFlags.INHIBIT_EXPLICIT_COMPLETIONS + if prefs.inhibit_word_completions: + flags |= sublime.AutoCompleteFlags.INHIBIT_WORD_COMPLETIONS + return flags + class LspResolveDocsCommand(LspTextCommand):