Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cursor position error #200

Open
JiaweiChenC opened this issue Nov 11, 2023 · 8 comments · Fixed by #222
Open

Cursor position error #200

JiaweiChenC opened this issue Nov 11, 2023 · 8 comments · Fixed by #222
Assignees

Comments

@JiaweiChenC
Copy link

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:
copilot_bug
the cursor will keep jumping to the end of the overlay.

Another similar situation:
another_bug
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)
@emil-vdw
Copy link
Collaborator

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. 🤔

@emil-vdw emil-vdw self-assigned this Dec 26, 2023
@emil-vdw emil-vdw reopened this Jan 12, 2024
@johnnywalker
Copy link

Is this the same issue reported with Typescript? #165

I often have issues with the cursor jumping in TS files, but that issue was closed as stale a while back.

@baongoc124
Copy link

I still have the same problem on latest master so upvoted this issue.

@jcs090218
Copy link
Member

I'll look into this!

@mostafah
Copy link

mostafah commented Jun 6, 2024

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.

output.mp4

@julian-hoch
Copy link

Same here, with typescript-mode (happens without lsp-mode / eglot). Colons, parentheses, braces are all affected.

@dov
Copy link

dov commented Jun 26, 2024

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:

wrong-cursor

@AndreaOrru
Copy link

I'm also experiencing this in Python.

aasseman pushed a commit to aasseman/copilot.el that referenced this issue Dec 21, 2024
Correct for indentation after accepting a completion rather than during
typing. This is less confusing than being impeded while typing spaces or
tabs on a new line while there is completion preview, and behaves more
like VSCode.

Fixes copilot-emacs#28 and copilot-emacs#200.
jcs090218 pushed a commit that referenced this issue Dec 22, 2024
Correct for indentation after accepting a completion rather than during
typing. This is less confusing than being impeded while typing spaces or
tabs on a new line while there is completion preview, and behaves more
like VSCode.

Fixes #28 and #200.

Co-authored-by: Alexis Asseman <[email protected]>
wangyuehong pushed a commit to wangyuehong/copilot.el that referenced this issue Dec 23, 2024
Correct for indentation after accepting a completion rather than during
typing. This is less confusing than being impeded while typing spaces or
tabs on a new line while there is completion preview, and behaves more
like VSCode.

Fixes copilot-emacs#28 and copilot-emacs#200.

Co-authored-by: Alexis Asseman <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

9 participants