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

Replace dots in the trigger with a different character that is visually the same #2293

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

ryuukk
Copy link
Contributor

@ryuukk ryuukk commented Jun 29, 2023

This helps cases with Sublime Text strips some completion items

Check the following issue for more details: sublimehq/sublime_text#6033

Question:

  1. trigger wont insert anything?
  2. if it inserts something, where would this trick be used instead?

@jwortmann
Copy link
Member

1. trigger wont insert anything?

Correct, as far as I can tell. It will use the original CompletionItem from the language server again, for the inserted text, so we are free to modify the trigger. But it will only have an effect on filtering.


Some observations:

  1. When I try this in a simplified example, it seems like the normal . in the trigger cannot be the single cause of this. The following example seems to work fine for me:
import sublime
import sublime_plugin
from typing import List, Optional


class CompletionsListener(sublime_plugin.ViewEventListener):

    def on_query_completions(self, prefix: str, locations: List[int]) -> Optional[sublime.CompletionList]:
        completion_list = sublime.CompletionList()
        sublime.set_timeout_async(lambda: self._on_query_completions_async(completion_list))
        return completion_list

    def _on_query_completions_async(self, completion_list: sublime.CompletionList) -> None:
        flags = sublime.DYNAMIC_COMPLETIONS | sublime.INHIBIT_REORDER
        trigger = "erro(fmt: string, args: ..any, location := caller_location)"  # unmodified
        # trigger = "erro(fmt: string, args: ꓸꓸany, location := caller_location)"  # U+A4F8
        # trigger = "erro(fmt: string, args: ․․any, location := caller_location)"  # U+2024
        annotation = "rt.erro: proc(fmt: string, args: ..any, location := caller_location)"
        completion = "erro"
        completions = [sublime.CompletionItem(trigger, annotation, completion)]
        sublime.set_timeout(lambda: completion_list.set_completions(completions, flags))

unmodified

So as a first step we should identify the root cause or the combination of factors which makes the completion not work in your example (linked issue). Just to exchange some random symbols might not work in all situations or even possibly make it worse for other examples.

  1. You chose a quite uncommon replacement symbol in this PR (Lisu Letter Tone Mya Ti) https://www.compart.com/en/unicode/U+A4F8
    I doubt that many fonts have support for this symbol, and probably use some fallback instead. It doesn't look very good here:

pr

Maybe this one would be a little bit better: https://www.compart.com/en/unicode/U+2024

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants