copilot-emacs / copilot.el

An unofficial Copilot plugin for Emacs.
MIT License
1.79k stars 126 forks source link

Out-of-order characters with typescript-mode when electric-indent-mode is activated and an active suggestion is shown #250

Open timcharper opened 8 months ago

timcharper commented 8 months ago

I've managed to reproduce this on a minimal setup, loading only typescript-mode (which activates electric-indent-mode, copilot.el (latest HEAD, 2c1c425).

https://asciinema.org/a/7j1X1KGr85Nl6Vm3VmlZnOS0o

Given the following (bold is typed, non-bold is suggestion, | is cursor):

add|(1, 2)

If I type a '(', and then type a ')', I end up with

add)|(

That is to say, the characters come out-of-order.

Disabling electric-indent-mode in typescript-mode resolves it.

For some reason, the out-of-order behavior doesn't happen with js-mode, even though electric-indent-mode is configured for those modes too. Further investigation required.

emil-vdw commented 8 months ago

Can you confirm the version of copilot.el you are running?

timcharper commented 8 months ago

@emil-vdw I'm running commit 2c1c425. According to the package header... "0.0.1" (probably not useful)

Emacs version is 29.1

timcharper commented 8 months ago

I have a functioning work-around.

https://gist.github.com/timcharper/faf25e59fcf1aee876f25a754395e40c

At least this will alleviate suffering to my fellow Emacs wielding typescript devs.

It's a bit horrible since the modification of copilot-completion-map is not buffer-local, so it bleeds to all modes. That could be improved. But, best would be the root issue can be solved.

johnnywalker commented 7 months ago

Thank you very much @timcharper !!

davidhaley commented 6 months ago

Thank you @timcharper

aaronyo commented 5 months ago

Thank you @timcharper