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

completion popup fails to display a CompletionItem until 3rd character is typed #6033

Open
ryuukk opened this issue Jun 28, 2023 · 5 comments

Comments

@ryuukk
Copy link

ryuukk commented Jun 28, 2023

Description of the bug

I have described the bug here: sublimelsp/LSP#2288 (comment)

Steps to reproduce

I can't test in safe-mode because it depends on the plugin LSP

  1. install odin compiler https://odin-lang.org/

  2. build ols https://github.com/DanielGavin/ols/

  3. install sublime LSP

  4. install sublime-odin: https://github.com/odin-lang/sublime-odin

  5. set this config:

    • replace the path of rt's collection to the one from the included test project eg:
      /home/user/Downloads/sublimebug/src/rt
    • replace ols path with yours
{
    "semantic_highlighting": true,
    "clients": {
        "odin": {
            "command": ["/home/ryuukk/dev/ols/ols"],
            "enabled": true,
            "selector": "source.odin",
            "settings": {
                "collections": [
                    { "name": "rt", "path": "/home/ryuukk/dev/kdomo/src/rt" },
                ],
                "enable_semantic_tokens": true,
                "enable_document_symbols": true,
                "enable_hover": true,
                "enable_snippets": true
            }
        },
    },

    "show_diagnostics_panel_on_save": 1,
    "diagnostics_panel_include_severity_level": 1,
    "log_server": ["panel"],
    "log_debug": true,
    "show_diagnostics_count_in_view_status": true,
    "inhibit_snippet_completions": true,
    "inhibit_word_completions": true,
    "semantic_highlighting": true,
}
  1. Download the project: sublimebug.zip
  2. unzip it and open it in sublime
  3. start the server
  4. open src/main_game.odin
  5. open the LSP console
  6. at line: 7, start to type: rt.te
  7. notice in the LSP console that the json responose for completion contains the test_message symbol from rt/dbg.odin
  8. notice that Sublime Text doesn't show the completion item
  9. now try to finish the sentence rt.tes < notice 3rd character we type, in the LSP log, we can see the same json response, and yet now Sublime Text shows the completiton item!

Expected behavior

Explained above in "Steps to reproduce"

Actual behavior

Explained above in "Steps to reproduce"

Sublime Text build number

4143

Operating system & version

Arch Linux x64

(Linux) Desktop environment and/or window manager

Openbox

Additional information

No response

OpenGL context information

No response

@ryuukk
Copy link
Author

ryuukk commented Jun 28, 2023

No completion shows up:

image

:: [22:40:47.515] --> odin textDocument/completion (81): {'position': {'character': 8, 'line': 6}, 'textDocument': {'uri': 'file:///home/ryuukk/dev/sublimebug/src/main_game.odin'}}
:: [22:40:47.517] <<< odin (81) (duration: 2ms): {'isIncomplete': True, 'items': [{'detail': 'rt.test_message: proc(fmt: string, args: ..any, location := caller_location)', 'insertTextFormat': 2, 'command': {'command': 'editor.action.triggerParameterHints', 'title': '', 'arguments': []}, 'documentation': '', 'filterText': 'test_message', 'label': 'test_message', 'deprecated': False, 'labelDetails': {'detail': '(fmt: string, args: ..any, location := caller_location)', 'description': ''}, 'insertText': 'test_message($0)', 'tags': [], 'kind': 3}]}

Notice, it's there in the json!!

How the Completion Item is being constructed:

trigger: test_message(fmt: string, args: ..any, location := caller_location)
annotation: rt.test_message: proc(fmt: string, args: ..any, location := caller_location)

Completion now do show up

image

i just typed a 3rd character, notice the same json received.. it doesn't make sense..

:: [22:44:31.314] --> odin textDocument/completion (84): {'position': {'character': 9, 'line': 6}, 'textDocument': {'uri': 'file:///home/ryuukk/dev/sublimebug/src/main_game.odin'}}
:: [22:44:31.317] <<< odin (84) (duration: 2ms): {'isIncomplete': True, 'items': [{'detail': 'rt.test_message: proc(fmt: string, args: ..any, location := caller_location)', 'insertTextFormat': 2, 'command': {'command': 'editor.action.triggerParameterHints', 'title': '', 'arguments': []}, 'documentation': '', 'filterText': 'test_message', 'label': 'test_message', 'deprecated': False, 'labelDetails': {'detail': '(fmt: string, args: ..any, location := caller_location)', 'description': ''}, 'insertText': 'test_message($0)', 'tags': [], 'kind': 3}]}

How the Completion Item is being constructed:

trigger: test_message(fmt: string, args: ..any, location := caller_location)
annotation: rt.test_message: proc(fmt: string, args: ..any, location := caller_location)

@ryuukk
Copy link
Author

ryuukk commented Jun 29, 2023

I found the issue!! it is due to the function definition

erro :: proc(fmt: string, args: ..any, location := #caller_location) 

If i remove the default #caller_location

Then the completitonitem shows up!

Is it a bug in sublime text? or in the language tm file for sublime?

If it's a problem in the tm file, can someone help me debug this?

https://github.com/odin-lang/sublime-odin

@rchl
Copy link

rchl commented Jun 29, 2023

I suppose it's a duplicate of #819.

Ideally those characters (the whole function arguments part) would not be part of the trigger because ST filters on those characters.

LSP has some heuristics for what to put there because ST doesn't allow to show one thing and filter on another thing like VSCode and some other editors do and what LSP really requires.

I suppose the most realistic is for the server or LSP to work around it or improve the heuristic.

@ryuukk
Copy link
Author

ryuukk commented Jun 29, 2023

After more testing, it also seems like the .. from ..any is causing the problem, if i remove .., it works, even with #caller_location

So when both are there, it causes the problem

Language server doesn't have to work around anything, LSP is editor agnostic, it is up to the editor to workaround things if it wants to support LSP

@ryuukk
Copy link
Author

ryuukk commented Jun 29, 2023

I submitted a PR for trick that solve this problem: sublimelsp/LSP#2293

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

No branches or pull requests

3 participants