Copilot在python下光标位置异常

在python mode下, 如果有个else,光标的位置会发生错误(跳到结尾的地方)。举个例子:

copilot_bug

猜测是因为copilot的补全会默认把光标放到补全开始或者结束的地方,这和当前的光标位置发生了冲突。 这个问题好像不能单纯把光标放到当前正确位置解决, 不然会有点奇怪 (会出现else|:的情况).

VScode 也有这个问题他们的解决方案是把补全放到光标后面等到确认补全的时候再缩进回来。

vscode_copilot

另外一个类似的bug情况:

another_bug

复现配置:

;; 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)