Skip to content

Commit

Permalink
fix: respect user-preferred flags when canceling completions (#2541)
Browse files Browse the repository at this point in the history
  • Loading branch information
rchl authored Nov 2, 2024
1 parent de767d1 commit 2b3a48c
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions plugin/completion.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"))
Expand Down Expand Up @@ -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:
Expand All @@ -263,15 +258,20 @@ def _cancel_pending_requests_async(self) -> None:
session.cancel_request(request_id, False)
self._pending_completion_requests.clear()

def _resolve_task_async(
self,
completions: list[sublime.CompletionItem],
flags: sublime.AutoCompleteFlags = sublime.AutoCompleteFlags.NONE
) -> None:
def _resolve_task_async(self, completions: list[sublime.CompletionItem], flags: sublime.AutoCompleteFlags) -> None:
if not self._resolved:
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):

Expand Down

0 comments on commit 2b3a48c

Please sign in to comment.