copilot-emacs / copilot.el

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

Fix jumping cursor bug #222

Closed emil-vdw closed 6 months ago

emil-vdw commented 6 months ago

Fix a bug where the cursor would jump to the end of the overlay when the completion candidate starts with a newline and the cursor is at the end of the current line.

This happens because setting the 'cursor property on a newline does not make the cursor show at the end of the line.

Implementation:

Closes #200.

zerolfx commented 6 months ago

You can merge it without approval or directly commit to the main branch.

zerolfx commented 6 months ago

The Emacs overlay is so tricky, and I'm unsure if a perfect solution exists.

david-krentzlin commented 6 months ago

This commit causes my setup to break. Working within double quotes will cause the cursor to jump behind the closing quote, which makes working with copilot.el impossible. The same is true for parentheses when I'm in lisp mode. It could be a combination of other things in my setup, which is why I just left a comment and didn't open a bug ticket.

I've pinned my package to the previous commit (653fe7b12990b5b7a050971bed4579022ce4b4f8) for now, which fixes the issue for me.

bclark-videra commented 6 months ago

I'm seeing the same issue @david-krentzlin describes in clojure-mode.

In my case, I'm using smartparens which inserts a matching closing delimiter (e.g. ), ") when the corresponding opening character is added. Disabling smartparens-mode resolves the issue.

Example: