sublimelsp / LSP

Client implementation of the Language Server Protocol for Sublime Text
https://lsp.sublimetext.io/
MIT License
1.65k stars 181 forks source link

Completion prefix not removed properly on completing fast #1248

Closed ryanpcmcquen closed 4 years ago

ryanpcmcquen commented 4 years ago

weird_completion

Please include in your report:

I haven't been able to reproduce it again to get a log, but when I do I will be sure to attach that as well. It has happened several times over the past few days.

ryanpcmcquen commented 4 years ago

Yay, got the log!

IndexError
Unable to open /Users/rmcquen/Library/Application Support/Sublime Text 3/Packages/LSP/LSP.sublime-settings
reloading settings Packages/User/LSP.sublime-settings
Unable to open /Users/rmcquen/Library/Application Support/Sublime Text 3/Packages/LSP/LSP.sublime-settings
Traceback (most recent call last):
  File "/Applications/Sublime Text.app/Contents/MacOS/Lib/python33/sublime_plugin.py", line 1381, in run_
    self.view.end_edit(edit)
  File "/Applications/Sublime Text.app/Contents/MacOS/Lib/python33/sublime.py", line 1072, in end_edit
    sublime_api.view_end_edit(self.view_id, edit.edit_token)
  File "/Applications/Sublime Text.app/Contents/MacOS/Lib/python33/sublime_plugin.py", line 846, in on_modified
    run_view_callbacks('on_modified', view_id)
  File "/Applications/Sublime Text.app/Contents/MacOS/Lib/python33/sublime_plugin.py", line 665, in run_view_callbacks
    callback(v, *args)
  File "/Applications/Sublime Text.app/Contents/MacOS/Lib/python33/sublime_plugin.py", line 147, in profiler
    return event_handler(*args)
  File "/Users/rmcquen/Library/Application Support/Sublime Text 3/Installed Packages/AutoFileName.sublime-package/autofilename.py", line 162, in on_modified
    sel = view.sel()[0].a
  File "/Applications/Sublime Text.app/Contents/MacOS/Lib/python33/sublime.py", line 846, in __getitem__
    raise IndexError()
IndexError
Traceback (most recent call last):
  File "/Applications/Sublime Text.app/Contents/MacOS/Lib/python33/sublime_plugin.py", line 1381, in run_
    self.view.end_edit(edit)
  File "/Applications/Sublime Text.app/Contents/MacOS/Lib/python33/sublime.py", line 1072, in end_edit
    sublime_api.view_end_edit(self.view_id, edit.edit_token)
  File "/Applications/Sublime Text.app/Contents/MacOS/Lib/python33/sublime_plugin.py", line 854, in on_selection_modified
    run_view_callbacks('on_selection_modified', view_id)
  File "/Applications/Sublime Text.app/Contents/MacOS/Lib/python33/sublime_plugin.py", line 665, in run_view_callbacks
    callback(v, *args)
  File "/Applications/Sublime Text.app/Contents/MacOS/Lib/python33/sublime_plugin.py", line 147, in profiler
    return event_handler(*args)
  File "/Users/rmcquen/Library/Application Support/Sublime Text 3/Installed Packages/Persistent Status Bar Line Number.sublime-package/persistent_status_bar_line_number.py", line 8, in on_selection_modified
    view.sel()[0].begin()
  File "/Applications/Sublime Text.app/Contents/MacOS/Lib/python33/sublime.py", line 846, in __getitem__
    raise IndexError()
IndexError
Traceback (most recent call last):
  File "/Applications/Sublime Text.app/Contents/MacOS/Lib/python33/sublime_plugin.py", line 1381, in run_
    self.view.end_edit(edit)
  File "/Applications/Sublime Text.app/Contents/MacOS/Lib/python33/sublime.py", line 1072, in end_edit
    sublime_api.view_end_edit(self.view_id, edit.edit_token)
  File "/Applications/Sublime Text.app/Contents/MacOS/Lib/python33/sublime_plugin.py", line 846, in on_modified
    run_view_callbacks('on_modified', view_id)
  File "/Applications/Sublime Text.app/Contents/MacOS/Lib/python33/sublime_plugin.py", line 665, in run_view_callbacks
    callback(v, *args)
  File "/Applications/Sublime Text.app/Contents/MacOS/Lib/python33/sublime_plugin.py", line 147, in profiler
    return event_handler(*args)
  File "/Users/rmcquen/Library/Application Support/Sublime Text 3/Installed Packages/AutoFileName.sublime-package/autofilename.py", line 162, in on_modified
    sel = view.sel()[0].a
  File "/Applications/Sublime Text.app/Contents/MacOS/Lib/python33/sublime.py", line 846, in __getitem__
    raise IndexError()
IndexError
Traceback (most recent call last):
  File "/Applications/Sublime Text.app/Contents/MacOS/Lib/python33/sublime_plugin.py", line 1381, in run_
    self.view.end_edit(edit)
  File "/Applications/Sublime Text.app/Contents/MacOS/Lib/python33/sublime.py", line 1072, in end_edit
    sublime_api.view_end_edit(self.view_id, edit.edit_token)
  File "/Applications/Sublime Text.app/Contents/MacOS/Lib/python33/sublime_plugin.py", line 854, in on_selection_modified
    run_view_callbacks('on_selection_modified', view_id)
  File "/Applications/Sublime Text.app/Contents/MacOS/Lib/python33/sublime_plugin.py", line 665, in run_view_callbacks
    callback(v, *args)
  File "/Applications/Sublime Text.app/Contents/MacOS/Lib/python33/sublime_plugin.py", line 147, in profiler
    return event_handler(*args)
  File "/Users/rmcquen/Library/Application Support/Sublime Text 3/Installed Packages/Persistent Status Bar Line Number.sublime-package/persistent_status_bar_line_number.py", line 8, in on_selection_modified
    view.sel()[0].begin()
  File "/Applications/Sublime Text.app/Contents/MacOS/Lib/python33/sublime.py", line 846, in __getitem__
    raise IndexError()
IndexError
Traceback (most recent call last):
  File "/Applications/Sublime Text.app/Contents/MacOS/Lib/python33/sublime_plugin.py", line 1381, in run_
    self.view.end_edit(edit)
  File "/Applications/Sublime Text.app/Contents/MacOS/Lib/python33/sublime.py", line 1072, in end_edit
    sublime_api.view_end_edit(self.view_id, edit.edit_token)
  File "/Applications/Sublime Text.app/Contents/MacOS/Lib/python33/sublime_plugin.py", line 846, in on_modified
    run_view_callbacks('on_modified', view_id)
  File "/Applications/Sublime Text.app/Contents/MacOS/Lib/python33/sublime_plugin.py", line 665, in run_view_callbacks
    callback(v, *args)
  File "/Applications/Sublime Text.app/Contents/MacOS/Lib/python33/sublime_plugin.py", line 147, in profiler
    return event_handler(*args)
  File "/Users/rmcquen/Library/Application Support/Sublime Text 3/Installed Packages/AutoFileName.sublime-package/autofilename.py", line 162, in on_modified
    sel = view.sel()[0].a
  File "/Applications/Sublime Text.app/Contents/MacOS/Lib/python33/sublime.py", line 846, in __getitem__
    raise IndexError()
IndexError
Traceback (most recent call last):
  File "/Applications/Sublime Text.app/Contents/MacOS/Lib/python33/sublime_plugin.py", line 1381, in run_
    self.view.end_edit(edit)
  File "/Applications/Sublime Text.app/Contents/MacOS/Lib/python33/sublime.py", line 1072, in end_edit
    sublime_api.view_end_edit(self.view_id, edit.edit_token)
  File "/Applications/Sublime Text.app/Contents/MacOS/Lib/python33/sublime_plugin.py", line 854, in on_selection_modified
    run_view_callbacks('on_selection_modified', view_id)
  File "/Applications/Sublime Text.app/Contents/MacOS/Lib/python33/sublime_plugin.py", line 665, in run_view_callbacks
    callback(v, *args)
  File "/Applications/Sublime Text.app/Contents/MacOS/Lib/python33/sublime_plugin.py", line 147, in profiler
    return event_handler(*args)
  File "/Users/rmcquen/Library/Application Support/Sublime Text 3/Installed Packages/Persistent Status Bar Line Number.sublime-package/persistent_status_bar_line_number.py", line 8, in on_selection_modified
    view.sel()[0].begin()
  File "/Applications/Sublime Text.app/Contents/MacOS/Lib/python33/sublime.py", line 846, in __getitem__
    raise IndexError()
IndexError
Traceback (most recent call last):
  File "/Applications/Sublime Text.app/Contents/MacOS/Lib/python33/sublime_plugin.py", line 1381, in run_
    self.view.end_edit(edit)
  File "/Applications/Sublime Text.app/Contents/MacOS/Lib/python33/sublime.py", line 1072, in end_edit
    sublime_api.view_end_edit(self.view_id, edit.edit_token)
  File "/Applications/Sublime Text.app/Contents/MacOS/Lib/python33/sublime_plugin.py", line 846, in on_modified
    run_view_callbacks('on_modified', view_id)
  File "/Applications/Sublime Text.app/Contents/MacOS/Lib/python33/sublime_plugin.py", line 665, in run_view_callbacks
    callback(v, *args)
  File "/Applications/Sublime Text.app/Contents/MacOS/Lib/python33/sublime_plugin.py", line 147, in profiler
    return event_handler(*args)
  File "/Users/rmcquen/Library/Application Support/Sublime Text 3/Installed Packages/AutoFileName.sublime-package/autofilename.py", line 162, in on_modified
    sel = view.sel()[0].a
  File "/Applications/Sublime Text.app/Contents/MacOS/Lib/python33/sublime.py", line 846, in __getitem__
    raise IndexError()
IndexError
Traceback (most recent call last):
  File "/Applications/Sublime Text.app/Contents/MacOS/Lib/python33/sublime_plugin.py", line 1381, in run_
    self.view.end_edit(edit)
  File "/Applications/Sublime Text.app/Contents/MacOS/Lib/python33/sublime.py", line 1072, in end_edit
    sublime_api.view_end_edit(self.view_id, edit.edit_token)
  File "/Applications/Sublime Text.app/Contents/MacOS/Lib/python33/sublime_plugin.py", line 854, in on_selection_modified
    run_view_callbacks('on_selection_modified', view_id)
  File "/Applications/Sublime Text.app/Contents/MacOS/Lib/python33/sublime_plugin.py", line 665, in run_view_callbacks
    callback(v, *args)
  File "/Applications/Sublime Text.app/Contents/MacOS/Lib/python33/sublime_plugin.py", line 147, in profiler
    return event_handler(*args)
  File "/Users/rmcquen/Library/Application Support/Sublime Text 3/Installed Packages/Persistent Status Bar Line Number.sublime-package/persistent_status_bar_line_number.py", line 8, in on_selection_modified
    view.sel()[0].begin()
  File "/Applications/Sublime Text.app/Contents/MacOS/Lib/python33/sublime.py", line 846, in __getitem__
    raise IndexError()
IndexError
rchl commented 4 years ago

There seems to be something really wrong with your ST if you are getting errors like

Unable to open /Users/rmcquen/Library/Application Support/Sublime Text 3/Packages/LSP/LSP.sublime-settings

Also notice that all of those stack traces are related to other packages.

ryanpcmcquen commented 4 years ago

I am on ST4.

rchl commented 4 years ago

Actually that might not be a problem. It probably means that you've opened LSP settings and you don't have any customizations. But all in all none of that seems related to your original issue.

ryanpcmcquen commented 4 years ago

Yeah, I can't get anything useful from the log but I am repro-ing the issue semi regularly. Here's my full package list if it helps:

{
    "bootstrapped": true,
    "in_process_packages":
    [
    ],
    "installed_packages":
    [
        "AutoFileName",
        "AutoPEP8",
        "Babel",
        "Clang Format",
        "DashDoc",
        "Debugger",
        "DiffTabs",
        "Dockerfile Syntax Highlighting",
        "DotENV",
        "DoxyDoxygen",
        "EditorConfig",
        "FileDiffs",
        "fish",
        "Function Name Display",
        "Gremlins",
        "JsPrettier",
        "LSP",
        "LSP-intelephense",
        "LSP-typescript",
        "MarkdownPreview",
        "Nord",
        "Package Control",
        "Persistent Status Bar Line Number",
        "PHP-Twig",
        "RawLineEdit",
        "RESTer HTTP Client",
        "RustFmt",
        "Sass",
        "SendToPasteBin",
        "StandardFormat",
        "SublimeLinter",
        "SublimeLinter-contrib-phpstan",
        "SublimeLinter-contrib-standard",
        "SublimeLinter-php",
        "Terminus",
        "uroboroSQL Formatter",
        "Witness color scheme",
    ],
    "repositories":
    [
    ],
}
sduman commented 4 years ago

I'm having this same problem with clangd so I'm guessing this is not a language specific issue. The only reproduction steps that I've managed to quantify is to use the arrow keys to select a completion and the whole thing fails immediately

Issue in action: https://imgur.com/a/haXUaAd

My LSP troubleshoot output is below.

Troubleshooting: clangd

Version

Active view

Project / Workspace

LSP configuration

{
  "clients": {
    "clangd": {
      "enabled": false
    }
  }
}

System PATH

rchl commented 4 years ago

I suppose the issue is related to triggering completion fast. If you wait two seconds or so, you probably won't be able to reproduce?

rwols commented 4 years ago

I played with this for a while and what I can find so far is that ST seems to be requesting completions more than once.

Given a buffer like this:

    mDevice->createev|

and typing enenter, I can sometimes get this sequence of events:

::  -> clangd textDocument/didChange: {'contentChanges': [{'rangeLength': 0, 'range': {'start': {'line': 264, 'character': 21}, 'end': {'line': 264, 'character': 21}}, 'text': 'e'}], 'textDocument': {'version': 497, 'uri': 'file:///Users/raoulwols/dev/tonic/src/ForwardRenderStrategy.cpp'}}
:: --> clangd textDocument/completion(169): {'textDocument': {'uri': 'file:///Users/raoulwols/dev/tonic/src/ForwardRenderStrategy.cpp'}, 'position': {'line': 264, 'character': 22}}
:: <<< clangd 169: {'items': [{'insertTextFormat': 2, 'sortText': '3e97ae13createEvent', 'detail': 'ResultValueType<vk::Event>::type', 'label': ' createEvent(const EventCreateInfo &createInfo) const', 'filterText': 'createEvent', 'insertText': 'createEvent(${1:const EventCreateInfo &createInfo})', 'textEdit': {'newText': 'createEvent(${1:const EventCreateInfo &createInfo})', 'range': {'start': {'character': 13, 'line': 264}, 'end': {'character': 22, 'line': 264}}}, 'kind': 2}, {'insertTextFormat': 2, 'sortText': '3e97ae13createEvent', 'detail': 'Result', 'label': ' createEvent(const vk::EventCreateInfo *pCreateInfo, const vk::AllocationCallbacks *pAllocator, vk::Event *pEvent) const', 'filterText': 'createEvent', 'insertText': 'createEvent(${1:const vk::EventCreateInfo *pCreateInfo}, ${2:const vk::AllocationCallbacks *pAllocator}, ${3:vk::Event *pEvent})', 'textEdit': {'newText': 'createEvent(${1:const vk::EventCreateInfo *pCreateInfo}, ${2:const vk::AllocationCallbacks *pAllocator}, ${3:vk::Event *pEvent})', 'range': {'start': {'character': 13, 'line': 264}, 'end': {'character': 22, 'line': 264}}}, 'kind': 2}, {'insertTextFormat': 2, 'sortText': '3e97ae13createEventUnique', 'detail': 'typename ResultValueType<UniqueHandle<Event, Dispatch> >::type', 'label': ' createEventUnique(const EventCreateInfo &createInfo) const', 'filterText': 'createEventUnique', 'insertText': 'createEventUnique(${1:const EventCreateInfo &createInfo})', 'textEdit': {'newText': 'createEventUnique(${1:const EventCreateInfo &createInfo})', 'range': {'start': {'character': 13, 'line': 264}, 'end': {'character': 22, 'line': 264}}}, 'kind': 2}], 'isIncomplete': False}
::  -> clangd textDocument/didChange: {'contentChanges': [{'rangeLength': 0, 'range': {'start': {'line': 264, 'character': 22}, 'end': {'line': 264, 'character': 22}}, 'text': 'n'}], 'textDocument': {'version': 498, 'uri': 'file:///Users/raoulwols/dev/tonic/src/ForwardRenderStrategy.cpp'}}
:: --> clangd textDocument/completion(170): {'textDocument': {'uri': 'file:///Users/raoulwols/dev/tonic/src/ForwardRenderStrategy.cpp'}, 'position': {'line': 264, 'character': 23}}
::  -> clangd textDocument/didChange: {'contentChanges': [{'rangeLength': 9, 'range': {'start': {'line': 264, 'character': 13}, 'end': {'line': 264, 'character': 22}}, 'text': ''}, {'rangeLength': 0, 'range': {'start': {'line': 264, 'character': 14}, 'end': {'line': 264, 'character': 14}}, 'text': 'createEvent(const EventCreateInfo &createInfo)'}], 'textDocument': {'version': 500, 'uri': 'file:///Users/raoulwols/dev/tonic/src/ForwardRenderStrategy.cpp'}}

which results in a buffer of

    mDevice->ncreateEvent(const EventCreateInfo &createInfo)

(The response to request 170 comes after commit_completion, and is irrelevant / discarded)


Typing enenter more slowly, I can get this sequence of events:

::  -> clangd textDocument/didChange: {'contentChanges': [{'rangeLength': 0, 'range': {'start': {'line': 264, 'character': 21}, 'end': {'line': 264, 'character': 21}}, 'text': 'e'}], 'textDocument': {'version': 459, 'uri': 'file:///Users/raoulwols/dev/tonic/src/ForwardRenderStrategy.cpp'}}
:: --> clangd textDocument/completion(148): {'textDocument': {'uri': 'file:///Users/raoulwols/dev/tonic/src/ForwardRenderStrategy.cpp'}, 'position': {'line': 264, 'character': 22}}
:: <<< clangd 148: {'items': [{'insertTextFormat': 2, 'sortText': '3e97ae13createEvent', 'detail': 'ResultValueType<vk::Event>::type', 'label': ' createEvent(const EventCreateInfo &createInfo) const', 'filterText': 'createEvent', 'insertText': 'createEvent(${1:const EventCreateInfo &createInfo})', 'textEdit': {'newText': 'createEvent(${1:const EventCreateInfo &createInfo})', 'range': {'start': {'character': 13, 'line': 264}, 'end': {'character': 22, 'line': 264}}}, 'kind': 2}, {'insertTextFormat': 2, 'sortText': '3e97ae13createEvent', 'detail': 'Result', 'label': ' createEvent(const vk::EventCreateInfo *pCreateInfo, const vk::AllocationCallbacks *pAllocator, vk::Event *pEvent) const', 'filterText': 'createEvent', 'insertText': 'createEvent(${1:const vk::EventCreateInfo *pCreateInfo}, ${2:const vk::AllocationCallbacks *pAllocator}, ${3:vk::Event *pEvent})', 'textEdit': {'newText': 'createEvent(${1:const vk::EventCreateInfo *pCreateInfo}, ${2:const vk::AllocationCallbacks *pAllocator}, ${3:vk::Event *pEvent})', 'range': {'start': {'character': 13, 'line': 264}, 'end': {'character': 22, 'line': 264}}}, 'kind': 2}, {'insertTextFormat': 2, 'sortText': '3e97ae13createEventUnique', 'detail': 'typename ResultValueType<UniqueHandle<Event, Dispatch> >::type', 'label': ' createEventUnique(const EventCreateInfo &createInfo) const', 'filterText': 'createEventUnique', 'insertText': 'createEventUnique(${1:const EventCreateInfo &createInfo})', 'textEdit': {'newText': 'createEventUnique(${1:const EventCreateInfo &createInfo})', 'range': {'start': {'character': 13, 'line': 264}, 'end': {'character': 22, 'line': 264}}}, 'kind': 2}], 'isIncomplete': False}
::  -> clangd textDocument/didChange: {'contentChanges': [{'rangeLength': 0, 'range': {'start': {'line': 264, 'character': 22}, 'end': {'line': 264, 'character': 22}}, 'text': 'n'}], 'textDocument': {'version': 460, 'uri': 'file:///Users/raoulwols/dev/tonic/src/ForwardRenderStrategy.cpp'}}
::  -> clangd textDocument/didChange: {'contentChanges': [{'rangeLength': 1, 'range': {'start': {'line': 264, 'character': 22}, 'end': {'line': 264, 'character': 23}}, 'text': ''}, {'rangeLength': 9, 'range': {'start': {'line': 264, 'character': 13}, 'end': {'line': 264, 'character': 22}}, 'text': ''}, {'rangeLength': 0, 'range': {'start': {'line': 264, 'character': 13}, 'end': {'line': 264, 'character': 13}}, 'text': 'createEvent(const EventCreateInfo &createInfo)'}], 'textDocument': {'version': 463, 'uri': 'file:///Users/raoulwols/dev/tonic/src/ForwardRenderStrategy.cpp'}}

which results in a buffer of

    mDevice->createEvent(const EventCreateInfo &createInfo)
rwols commented 4 years ago

I guess ST's internal prefix removal logic resets upon every completion request. Which makes sense. But ST should not do a second request in the first place. isIncomplete = false so that's not at play here.

rchl commented 4 years ago

Can't reproduce this one. Neither with intelephense nor with my simple plugin based on @rwols' payloads: https://gist.github.com/rchl/721c69ab2a01794f07a48841828605df

If it's an actual ST bug, we should find a way to reproduce and submit an issue.

predragnikolic commented 4 years ago

I think that the COMPLETION_FLAG_KEEP_PREFIX flag is not working correctly in the later ST builds. I tried ST 4085 and 4083 and I can reproduce the issue with LSP-elm:

output

rchl commented 4 years ago

Can you post logs? We still don't have a reliable way to reproduce.

predragnikolic commented 4 years ago

here are my logs, that should be simpler to follow. I added 4 print statements,

  1. When sending the completion request.
  2. When receiving the completion response.
  3. When selecting the completion item.
  4. When we notify the server of a change event

This bug only occurs when we select the completion item before we receive the response for the last request.

notify did change
notify did change
notify did change
send completions request 2
receive response 2
notify did change
send completions request 3
selected item {'textEdit': {'newText': 'Image', 'range': {'end': {'line': 0, 'character': 6}, 'start': {'line': 0, 'character': 5}}}, 'kind': 20, 'label': 'Image', 'sortText': 'b_Image'}
receive response 3
notify did change

b4083

If we select the completion item after we receive the last completion response, everything works as expected.

notify did change
send completions request 4
receive response 4
notify did change
selected item {'textEdit': {'newText': 'Image', 'range': {'end': {'line': 0, 'character': 7}, 'start': {'line': 0, 'character': 5}}}, 'kind': 20, 'label': 'Image', 'sortText': 'b_Image'}  // this is ok, we selected the completion item after we received the last completion response
notify did change
rchl commented 4 years ago

I was thinking LSP logs :). Are those completions returned with dynamic completions flag?

predragnikolic commented 4 years ago

I can reproduce the issue even without the dynamic flag.

Let me breakdown what I think is going on.

send completions request 2 // ST Sets the KEEP PREFIX - (prefix == 'I')

1|type I|

receive response 2 // received CompletionItems for request 2

1|type I|
       ___________
       | Image
       |

notify did change // continue typing to trigger a new completion request

1|type Ima|
       ___________
       | Image
       |

send completions request 3 // ST Sets the KEEP PREFIX for completions request 3, (prefix == 'Ima')

selected item // but we immediately select the completion item that was received from request 2

    {'textEdit': {'newText': 'Image', 'range': {'end': {'line': 0, 'character': 6}, 'start': {'line': 0, 'character': 5}}}, 'kind': 20, 'label': 'Image', 'sortText': 'b_Image'}

So what happens is the following. ST leaves the prefix newest prefix (that was set for request 3, but we selected a completion item recieved from request 2), which in this case is 'Ima' (prefix == 'Ima') which is the wrong prefix for the request 2. For the request 2 I expect the Keep prefix to be "I".

So ST leaves the prefix "Ima" and we apply the text edit which leaves us with the following state:

1|type Imagema|

receive response 3 // we receive the response for request 3 notify did change

rchl commented 4 years ago

The thing is, only one completion request is normally triggered in such cases - only with dynamic flag completions are requested for each keystroke. If you are getting multiple completion requests without dynamic flag then that's the root issue most likely.

And I'd like to know how to reproduce that so that we can create minimal test case.

predragnikolic commented 4 years ago

only with dynamic flag completions are requested for each keystroke

Even without the dynamic flag, the on_query_completions is called on each keystroke. (which means that we send the completion request on each keystroke).

Correct me if I am wrong, the DYNAMIC_COMPLETIONS is used by ST to update the completion items in the AC popup when ST is already showing the AC popup. (We use it in LSP when isIncomplete is true, so we don't have to hide and show the AC to make the new Completion items visible in the AC popup)

rchl commented 4 years ago

Even without the dynamic flag, the on_query_completions is called on each keystroke. (which means that we send the completion request on each keystroke).

Well, that's not right then. :)

I wonder if this looks any special:

view.settings().get('auto_complete_selector')

If it's not that then probably you are the only one that can figure it out as it's not normal behavior that happens with all files and servers. Maybe some other installed package affects it? Can you reproduce in safe mode with just a bare minimum of packages installed?

predragnikolic commented 4 years ago

I was wrong, I was pretty certain that the on_query_completion was called on each keystroke without the flag. It is not.

only with dynamic flag completions are requested for each keystroke

This here is correct.

rchl commented 4 years ago

Just to clarify: so all your results were with DYNAMIC_COMPLETIONS flag set?

predragnikolic commented 4 years ago

Just to clarify: so all your results were with DYNAMIC_COMPLETIONS flag set?

Yes,

but even if I remove this code, I can still reproduce the issue that you saw in the gif above.

             response_items = response["items"] or []
-            if response.get("isIncomplete", False):
-                flags |= sublime.DYNAMIC_COMPLETIONS
rchl commented 4 years ago

In that case, maybe you can figure out why it's the case.

predragnikolic commented 4 years ago
rchl commented 4 years ago

view.settings().get('auto_complete_selector')

Sorry, I meant auto_complete_triggers. But probably it's a dead-end anyway.

Can I even test this in safe mode?

I guess it might be tricky. But since you are on Linux it should be pretty easy to test by creating a separate, clean profile (or rename the main one for testing).

I've tried with LSP-elm and can't reproduce here. It doesn't even use isIncomplete: true by default which I had impression it does for you.

rwols commented 4 years ago

The new alpha build 4086 mentions fixes relating to the prefix removal. Perhaps this is now fixed?

predragnikolic commented 4 years ago

I can confirm that it is fixed with ST build 4086