copilot-emacs / copilot.el

An unofficial Copilot plugin for Emacs.
MIT License
1.71k stars 122 forks source link

Dropped input characters and cursor placement issues around closing parentheses #228

Closed sangaline closed 5 months ago

sangaline commented 6 months ago

I've been consistently seeing some strange behavior around closing parentheses and curly brackets. Here's a gif that demonstrates it:

copilot

On line 6, I type myFunction(); but the closing ) is dropped and I get myFunction(;. I then insert a ) between ( and ; but the ) is put after the ; instead of before it. Then on line 8 I try typing myFunction()); to make up for the ) being dropped when typed a single time, and it adds back the dropped ) in addition to the second one so I end up with )). This creates a difficult situation because it means there's no way to close brackets other than going back and fixing things after they've been entered incorrectly.

I'm using a relatively vanilla Doom Emacs install with electric-pair-mode and snippets disabled. I'm on the latest 1542d76 commit of copilot-emacs. Things behave normally if I disable copilot-mode, but I'm not sure if it's an interaction with another package or an issue with copilot-mode itself. Happy to provide any further debugging info if you let me know what would be relevant.

emil-vdw commented 5 months ago

This must be from the jumping cursor bugfix. I think it doesn't play well with electric-pair-mode.

matthemsteger commented 5 months ago

This latest change made this library unusable also if you use https://github.com/Fuco1/smartparens. I don't know the usage percentage of electric-pair-mode and smartparens, but the jumping cursor bug was a lot less of an issue at least for me (in fact I dont think I noticed it before).

With smartparens, if you type a character that is part of the copilot complete, it closes the paren (or curly or whatever) and continues completing and you end up with a garbled mess.

Going back to the commit before the above jumping cursor fix is a lot smoother experience and make copilot usable in emacs + smartparens again.

emil-vdw commented 5 months ago

@sangaline, @matthemsteger it must indeed be very annoying. This bug will have the highest priority for me and I hope to have it fixed before end of next week.

jimeh commented 5 months ago

I'm having the same issue after #222 with smartparens-mode. In case it helps, here's a demo:

https://github.com/copilot-emacs/copilot.el/assets/39563/0be8b66f-9a3e-4527-bf1c-89688425af46

martin-dimi commented 5 months ago

Same here. This is a very annoying bug. Had to stop using copilot altogether because of it. Please prioritise 🙏

emil-vdw commented 5 months ago

@martin-dimi for now you can use an older commit until it is fixed. You can use 653fe7b12990b5b7a050971bed4579022ce4b4f8.

jimeh commented 5 months ago

@emil-vdw I could be wrong, but this new issue caused by #222 seems worse than the issue it fixed. What do you think about reverting #222 until a fix addressing both is ready?

emil-vdw commented 5 months ago

@jimeh that's probably best. I will revert shortly.

sangaline commented 5 months ago

@emil-vdw I'm unfortunately still seeing the same behavior after the revert. Unlike some others here, I am not using electric-pair-mode or smartparens-mode. I don't have anything configured to insert closing brackets automatically.