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

fix: respect user-preferred flags when canceling completions #2541

Merged
merged 2 commits into from
Nov 2, 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
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