copilot-emacs / copilot.el

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

Weird rendering / positioning issues with company-box and copilot. #109

Closed wusticality closed 1 year ago

wusticality commented 1 year ago

I've been using company-box in conjunction with this package. In some cases, it works as expected:

image

Here, both lsp-mode candidates and copilot candidates are shown. However, other times, things to not work as expected, namely, the position of the company-box child frame is moved by the copilot candidate overlay, and the color of the child overlay for company-box is affected by the background color of the copilot overlay:

image

This happens about 50% of the time for me. Thanks!

zerolfx commented 1 year ago

https://github.com/zerolfx/copilot.el/blob/d4519e178217309833b98eb0f2bfbddc4edb4c2e/copilot.el#L539

Please try to remove this line and see what happens.

wusticality commented 1 year ago

Hey, thanks for the prompt response. Commented out that line but it's still happening once the candidate is rendered in the copilot overlay:

image

zerolfx commented 1 year ago

Sorry for missing some essential details.

I can't reproduce this problem, so I can't help you much.

Removing this line should fix the color problem but not the position problem. After confirming the color problem is fixed, you can work on fixing the position problem, which is overlay-related. My solution for the position problem is using that copilot--posn-advice, but in your case, it seems to be inadequate and fails 50% of the time.

wusticality commented 1 year ago

Heya, thanks again for your time. Interesting that you're not seeing this on your end. Have you tried using copilot in conjunction with something like lsp-mode that has some latency? This behavior happens both on my Linux box and on my MacBook Pro.

Near as I can tell, it seems to happen if copilot has candidates to display before company-box. If so, the company-box child frame gets pushed to the right of it. Perhaps a way to reproduce this on your end would be to show a company-box after a delay or to try using lsp-mode which has more latency? I'm happy to help in any way that I can.

Commenting out that advice doesn't seem to help either way.

zerolfx commented 1 year ago

~I can reproduce this problem after upgrading all my plugins. I will investigate it soon.~ Though I'm using the combination of company-box + lsp-mode, I didn't often use Emacs recently and hadn't noticed the problem.

Fixed again. The previous fix (by copilot--posn-advice) was invalidated by two previous improvements.

wusticality commented 1 year ago

Thanks so much for this, at least on my MacBook pro, the positioning issue appears to be fixed. The color issue still occurs though (the company-box child frame taking the color of the copilot overlay):

image

You can see that the color of the child frame on the right, and the documentation frame on the left are colored incorrectly.

I won't be able to test on my Linux box until I'm back home in a week or so.

zerolfx commented 1 year ago

image

@wusticality Are there any specific prerequisites required to trigger the color issue, such as only happening at the end of lines? I'm unable to reproduce the issue on my end.

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.