TerminalFi / LSP-copilot

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

fix: align accept completion logic with VSCode #60

Closed timfjord closed 2 years ago

timfjord commented 2 years ago

In VSCode when the cursor is at the beginning of the line and there is a visible completion, the completion gets accepted only when the cursor is literally near the completion.
So, for example, when the cursor is at the beginning of the line and the completion is a few tabs/stop away then accepting a completion(e.g. pressing the tab) won't accept the completion and instead trigger the tab key.

https://user-images.githubusercontent.com/471335/193867633-2130301a-4591-466a-8e80-8e350f3321e4.mov

This PR emulates this logic by adding a query context that is used by default.
It is important to either keep this logic default or remove the default keymap for the tab at all because otherwise there will be no way to override the tab key in the user keymaps.

https://user-images.githubusercontent.com/471335/193867564-73603493-8ee6-48e4-9d47-64ea10c64714.mov

Also, this change should play nicely with this one https://github.com/TheSecEng/LSP-copilot/issues/52
So once https://github.com/TheSecEng/LSP-copilot/issues/52 is implemented the completion will be updated right away without an extra request/delay(similar to VSCode)

jfcherng commented 2 years ago

Looks good. Just need to run black or make fix.

timfjord commented 2 years ago

Great. Will do that now. Also some of the suggestions have broken the functionality. Checking everything now

timfjord commented 2 years ago

Great, now it is working. The regex caused the issue

timfjord commented 2 years ago

Just found another issue with the implementation, the fix is on its way - https://github.com/TheSecEng/LSP-copilot/pull/61