Skip to content

Commit

Permalink
fix: use user-preferred flags when canceling completions
Browse files Browse the repository at this point in the history
  • Loading branch information
rchl committed Oct 30, 2024
1 parent de767d1 commit 315016f
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 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 @@ -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):

Expand Down

0 comments on commit 315016f

Please sign in to comment.