Closed CeleritasCelery closed 1 year ago
Thanks for your work. You have solved a long-standing problem.
I made some minor changes by refactoring the code and changing the meaning of the end
property from length to absolute position. Additionally, I removed the calls to goto-line
, as it is only intended for interactive use.
Thanks. I initially tried to use end as an absolute position like you did, but it doesn't work when you have automatic pair insertion (via smartparens, electric-pair-mode, cleverparens, etc). The issue is that if I insert (
it will also insert )
. The end position should move forward 2 places, but we only advance it one with cl-incf
. I don't know of a reliable way to detect the auto-pair case, so that is why I defined end
to be an offset from the end of the line.
Oh no, I haven't tested that case. I will revert my changes if there is a bug.
Currently copilot.el assumes that the completion text will go all the way to the end of the line, but this is not always the case. When this happens it will lead to incorrectly deleting the text that used to be there. This will lead to unbalanced parens or quotes.
This PR fixes this by using the API's
:end
property to determine where the end of the completed text should go.Example: text given to copilot
copilot will return the text
world
.With the current implementation this will be the result if the user accepts the completion:
After this PR, the result would be as expected:
This will resolve issues like #77 #62 #117