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

Inconsistent autocomplete behavior #745

Closed
basaran opened this issue Oct 3, 2019 · 9 comments
Closed

Inconsistent autocomplete behavior #745

basaran opened this issue Oct 3, 2019 · 9 comments
Labels
language server issue Issues related to language servers communicating with this plugin

Comments

@basaran
Copy link

basaran commented Oct 3, 2019

Description

When you invoke sublime's autocomplete without any string, a consequent invocation will not show any LSP information. Please see the gif.

lsp-php

Steps to reproduce

  1. Type Req inside a method, and invoke autocomplete via shortcut.
  2. Observe LSP is providing the use statement for Request class.
  3. Delete everything, go to method, just invoke autocomplete via shortcut and type Req. Nothing is provided by LSP.
  4. Move the block down by a line, type Req and invoke autocomplete. Notice LSP is working again.

Unless the line is moved, or the parenthesizes removed, LSP will not work again, defaulting to sublime autocomplete only.

Expected behavior

LSP should always show the hints when the autocomplete is invoked.

Environment

  • Build: 3210
  • Operating system and version: Linux Arch
  • [Linux] Desktop Environment and/or Window Manager: Awesomewm

Also submitted to:
sublimehq/sublime_text#3005

@tomv564
Copy link
Contributor

tomv564 commented Oct 3, 2019

Hi, thanks for the detailed report. I feel a bit unclear from the extra steps before/after step 3. Could it be that triggering the completion shortcut before typing Req that causes the issue?

Could you try two things:

  • Set log_debug and log_payloads to True, restart Sublime and share the sublime console log for only the "trigger completion and type Req" part of the repro?
  • See if the behaviour is the same with the only_show_lsp_completions LSP package setting set to True?

@basaran
Copy link
Author

basaran commented Oct 4, 2019

Hello, I made you a new screen capture. My autocomplete is set to ctrl+space.

lsp

Making another one with the only_show_lsp_completions shortly, and with the log as well.

@basaran
Copy link
Author

basaran commented Oct 4, 2019

Here's another capture with lsp only set to true:

lsp-only

and this is the log:

lsp_only.txt

@tomv564
Copy link
Contributor

tomv564 commented Oct 4, 2019

That's much clearer, thanks.
In the logs I see 5 requests for completions to intelephense, with responses alternating between data, empty, data, empty, data.

In your screenshot you can also see an empty response in the console when you are pressing ctrlspace after deleting the first "Req":

LSP:  --> textDocument/completion
LSP:      {'items': [], 'isIncomplete': False}

Once intelephense sends an empty response at a given location, we will cache it until you edit the document.

If you can get some logging from the server then we could know for sure, but I suspect intelephense thinks the document is in a different state than your editor shows.

@basaran
Copy link
Author

basaran commented Oct 4, 2019

I noticed that too, it seems invoking the autocomplete with no input does not trigger the LSP hints. After that, even if you type something in, it seems think nothing has changed, unless you remove the brackets or shift the line to another line and then type in something.

So, you think the problem is with lsp-intelephense?

It also seems this is only a problem when you have the sublime's auto_complete set to off. Look at it with the "auto_complete": true

autoon

But it still goes back to the buggy behavior as soon as yo hit ctrl+space and invoke the autocomplete manually.

@tomv564
Copy link
Contributor

tomv564 commented Oct 5, 2019

Yes, most servers return completion items if the completion request has no characters preceding the cursor. Intelephense's choice not to is the cause for what you're seeing with LSP.

Have you tried VS Code with intelephense? If the behaviour there is better then we can have a closer look at their handling of empty responses.

@tomv564 tomv564 added language server issue Issues related to language servers communicating with this plugin and removed bug labels Oct 5, 2019
@basaran
Copy link
Author

basaran commented Oct 7, 2019

Tested with VS Code + Intelephense. It has the same behavior, if you invoke the code complete with nothing typed in, it only gives you local suggestions. However, it's able to recover without moving things around. I did it twice so it can be seen easier.

Capture:

vscode

Note: There is a whole bunch of code at the bottom outside the scope of the recorder with the Request keyword already in. That's where the local "Request" is coming from.

tomv564 added a commit that referenced this issue Dec 10, 2019
If there are no completion results, typing view.s would trigger requests at both '.' and 's'.
tomv564 added a commit that referenced this issue Dec 10, 2019
* Don't run on_completion_inserted on insert_best_completion

Pressing <tab> in documents results in huge "LSP: No match for inserted "<entire document>.." entries in the console.

* Don't cancel requested completions for the exact same word while typing ahead.

If typing view.settings, completion at dot is cancelled by "s", "e" etc. even though original request is still relevant

* Don't present completion results from previous word

If typing view.settings() quickly, a popup would show at the cursor offering "settings()".
In the response handler, we detect if cursor has passed a word boundary and ignore the result if so.

* Revert fix for #745, causing extra requests after trigger character

If there are no completion results, typing view.s would trigger requests at both '.' and 's'.
@tomv564 tomv564 reopened this Dec 10, 2019
@tomv564
Copy link
Contributor

tomv564 commented Dec 10, 2019

Re-opening because I reverted the fix for causing extra completion requests on all servers.

I think it can be fixed by differentiating between self.completions is [] (server replied no results, try again with more chars) and self.completions is None (waiting for reply, don't send more requests)

@rwols
Copy link
Member

rwols commented Apr 6, 2020

I propose to wontfix for ST build 3211. For later builds of ST, we'll have the completion logic almost entirely rewritten. Including having way less state, so what you're asking for is probably fixed alongside the changes.

@rwols rwols closed this as completed Apr 6, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
language server issue Issues related to language servers communicating with this plugin
Projects
None yet
Development

No branches or pull requests

3 participants