copilot.el
copilot.el copied to clipboard
Cursor position error
When the real cursor position is not at the start of the overlay preview. The cursor will jump to the end of the overlay.
For example:
the cursor will keep jumping to the end of the overlay.
Another similar situation:
the cursor's real position is after :, but it will jump to the end of the completion.
To reproduce:
emacs -Q -l test.el test.py
;; test.el
(package-initialize)
;; straight.el initialization
(defvar bootstrap-version)
(let ((bootstrap-file
(expand-file-name "straight/repos/straight.el/bootstrap.el" user-emacs-directory))
(bootstrap-version 6))
(unless (file-exists-p bootstrap-file)
(with-current-buffer
(url-retrieve-synchronously
"https://raw.githubusercontent.com/radian-software/straight.el/develop/install.el"
'silent 'inhibit-cookies)
(goto-char (point-max))
(eval-print-last-sexp)))
(load bootstrap-file nil 'nomessage))
(add-to-list 'package-archives
'("melpa" . "https://melpa.org/packages/"))
;; Location of my use-package git clone
(add-to-list 'load-path "~/.emacs.d/.local/straight/repos/use-package/")
(require 'use-package)
(use-package copilot
:straight (:host github :repo "zerolfx/copilot.el" :files ("dist" "*.el"))
:ensure t)
(add-hook 'prog-mode-hook 'copilot-mode)
It seems that this happens when the first character of the completion is a newline and the code is attempting to set the cursor property on the newline character. :thinking:
Is this the same issue reported with Typescript? https://github.com/copilot-emacs/copilot.el/issues/165
I often have issues with the cursor jumping in TS files, but that issue was closed as stale a while back.
I still have the same problem on latest master so upvoted this issue.
I'll look into this!
If it helps, here’s another reproduction of the issue that happens for me all the time. Here after if
I type (
instead of hitting tab because I want to write something other than the suggestion. The (
does not show behind the suggestion, but it’s there and later appears after what I type. This is typescript-mode with lsp-mode. Everything should be latest version, I suppose.
https://github.com/copilot-emacs/copilot.el/assets/531910/b4bb41fa-834b-4586-8055-ca2e38f2cb63
Same here, with typescript-mode (happens without lsp-mode / eglot). Colons, parentheses, braces are all affected.
It happens in python model as well, that sometimes the cursor is placed at the end of the suggestion instead of the beginning. E.g. in the following image the last character input by my was ":", the rest was filled in by copilot and the cursor is shown at the end of the suggestion, instead of the beginning:
I'm also experiencing this in Python.