copilot-emacs / copilot.el

An unofficial Copilot plugin for Emacs.
MIT License
1.74k stars 124 forks source link

some characters of suggested compeltion are being consumed when user types the completion manually #134

Closed svatem1 closed 1 year ago

svatem1 commented 1 year ago

I'm using copilot.el with Spacemacs (with default vi-like keybindings) and I've set it up exactly as stated in your documentation. What's happenning to me and renders this poorly usable is the following: I'm in insert mode and typing code, I make (even short) pause in my typing and copilot suggests some completion. If I press Tab, everything is completed. If I do not pres Tab and type the same code myself (so that my typed code equals to the suggested one), if there is a comma character in suggested code, after I type it, it gets consumed. Eg.: I type console.log("res and now copilot shows ponse", response);. If I continue typing console.log("response" and now I press ,, this comma gets consumed and is not part of typed text even if I pressed it and I end up with console.log("response" response). Now - why would I do it instead of pressing Tab? I do type very fast and sometimes my mind/fingers just type what I need faster then realizing I could press Tab and get it completed, usually it's when the completion is something very short. So I end up correcting what I typed very often, because copilot is messing what I write.

zerolfx commented 1 year ago

copilot.el will delete code only in two situations:

Based on your description, I cannot determine if either of these cases occurred and therefore do not know why the comma was removed.

You could try printing something around the only usage of delete-region in copilot.el to see if it's responsible for deleting the comma.

svatem1 commented 1 year ago

I am not proficient with emacs-lisp debugging. Nor am I interested in developing this plugin. I provided imho valuable feedback, to me it seems like it's not hard to reproduce this based on my description. I'm grateful for what you provide as long as it is of some use to me (currently very limited as it causes more harm than good), but I have my projects to work on.

zerolfx commented 1 year ago

I was unable to reproduce the issue on my end, so I believe it may be due to a conflict with a plugin.

Let's keep this issue open and see if anyone else has experienced similar problems.

wizzomafizzo commented 1 year ago

I'm not sure if this is related but it sounds quite similar. I am having the opposite(?) problem. The package seems to be inserting the last character of a completion if I type the exact completion out manually. For example:

I can make this happen very consistently on short completions. Otherwise I have noticed no issues.

Here is an animation of it happening:

emacs_uQ12TuJN4n

I am on Windows running Emacs 29.0.60

zerolfx commented 1 year ago

@wizzomafizzo fixed, see also #133

wizzomafizzo commented 1 year ago

@zerolfx thank you mate!

svatem1 commented 1 year ago

@zerolfx If you tell me what / how to do, I can do it and e.g. copy some log messages. What I'm seeing in copilot events buffer are these: [stderr] (node:67698) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 change listeners added to [EventEmitter]. Use emitter.setMaxListeners() to increase limit This is what I'm experiencing when editing and completely ignoring the suggestions (all nonsense, that you see is me fighting with editing while being in insert mode, I've never experienced it without copilot) https://streamable.com/cgu7ke

github-actions[bot] commented 1 year ago

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.

github-actions[bot] commented 1 year ago

This issue was closed because it has been stalled for 5 days with no activity.