TerminalFi / LSP-copilot

GitHub Copilot support for Sublime Text LSP plugin provided through Copilot.vim.
625 stars 25 forks source link

fix: do not get completions during the lsp_save command #59

Closed timfjord closed 1 year ago

timfjord commented 1 year ago

Some LSP servers are slower than others, and, for example, formatting on save (that is caused by the lsp_save command) can take a bit longer.
Because of that, the on_modified_async callback gets triggered in the middle of the call and a completion gets displayed(because it may have formatted the source code).

This PR blocks the completion request during the lsp_save command duration

Closes #55

timfjord commented 1 year ago

@TheSecEng @jfcherng any comments on this one?

jfcherng commented 1 year ago

The codes look fine. I am just not sure how this will improve UX since I don't use lsp_save.

image https://discord.com/channels/280102180189634562/280102180189634562/1022480894172352594

But it looks like modifying the view buffer during formatting is okay (effectively ignoring the formatted result), so I don't know why we don't allow to request copilot completion. Is it because LSP gets stuck by that lsp_save command so the request will be handled after the saving command gets done?

timfjord commented 1 year ago

Currently(without this fix), saving a file sometimes causes a completion popup to apear, even if you haven't typed anything. It is because when the lsp_format_on_save is set, the save command formats(chages) the file under the hood that requests new completions.

With this fix in place, it doesn't request any completion for the duration of the lsp_save command

TerminalFi commented 1 year ago

LGTM