-
Notifications
You must be signed in to change notification settings - Fork 124
fix(suggestion): Trigger suggestion on InsertEnter #318
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
Conversation
@zbirenbaum any chance we can have this merged? |
Nevermind, this PR seems to break in a lot of other ways |
Can you give me some examples of bugs this introduce? I'm using this PR with no issue, at least for suggestions (I'm not using panels and other features). |
Haven't looked into it, but I started getting errors where suggestions tried to show when it was not allowed to change the buffer |
Thank you for your response. I rebased my fork and will use this PR with the latest changes for the next few days to see if I can reproduce. |
Great, I'm also using the update branch. Will let you know when I experience issues but seems to work fine now. |
I also tried that updated commit and it doesn't work the first time I open a new line in a newly opened file. If I hit escape, and then open the line again it works. Doesn't matter if I wait for a while. I.e. only works 2nd and subsequent times I open a new line. I am doing the test I described here in both a Python file and a shell script. |
Thank you @bulletmark for your feedback, I will check this weekend and see if I can reproduce and fix |
@bulletmark I could not reproduce the error, here is a screen recording showing Copilot working using Screen.Recording.2025-01-31.at.18.14.45.movI could reproduce the buggy behavior using lazy loading, and removing I tried to use lazy loading in my config and manually trigger a suggestion when entering insert mode the first time, but the server is not ready yet |
Great. Just changed it in LAzyVim and works as expected indeed. |
So, is there an estimated date when this will be implemented in LazyVim? I just opened today nvim to work on some stuff and just came across this exact issue hahaha, and modifying my config files does not seem to change the behavior. |
@ADPenrose what do you mean? LazyVim != copilot.lua |
Or you mean that LSP notification? That's already solved on main |
Have been using this PR for a while now without issues, so would be great if this could get merged. Thank you! |
This looks good to me, merging. Thanks for the fix @jsongerber |
Yay, updated LazyVim which picked up this change. Then tested against my two fibanacci examples (python and shell) and it worked perfectly! Thanks. |
This pull request make that the suggestion get triggered when entering insert mode.
It was not working because both
InsertEnter
andCursorMovedI
would fire at the same time and the timer variable would be messed up in the debounce function like this:InsertEnter
is called,copilot.timer
is set to timer id 1CursorMovedI
is called,copilot.timer
is set to timer id 2timer
is 1,copilot.timer
is 2, early return,copilot.timer
is set tonil
timer
is 2,copilot.timer
isnil
, early returnThis pull requests fixes this, I'm testing this since yesterday and it's working fine, but I don't know the codebase very well so I'm hoping I'm not breaking something.
Also the debounce function doesn't seem to be working (with or without this pull request), it works only as a timeout, does this need to be fixed or is this the intended behavior?