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

error duing copilot--on-doc-change in vertico completions #286

Open
offbyone opened this issue Mar 23, 2024 · 1 comment
Open

error duing copilot--on-doc-change in vertico completions #286

offbyone opened this issue Mar 23, 2024 · 1 comment

Comments

@offbyone
Copy link

I've just started, after a recent doom update, getting an error the first time I try select a completion from the minibuffer using vertico. The traceback implicates copilot-mode's copilot--on-doc-change function. I am not sure why this is happening or how to get you better debugging info, but something is fishy here:

Debugger entered--Lisp error: (wrong-type-argument utf-8-string-p "  roles:\370\210\200\200\202")
  json-serialize((:jsonrpc "2.0" :method "textDocument/didChange" :params (:textDocument (:uri "buffer://%20*Minibuf-1*" :version 4) :contentChanges [(:range (:start (:line 0 :character 0) :end (:line 0 :character 0)) :text "  roles:�")])) :false-object :json-false :null-object nil)
  jsonrpc--json-encode((:jsonrpc "2.0" :method "textDocument/didChange" :params (:textDocument (:uri "buffer://%20*Minibuf-1*" :version 4) :contentChanges [(:range (:start (:line 0 :character 0) :end (:line 0 :character 0)) :text "  roles:�")])))
  #f(compiled-function (arg1 &rest rest) "Send MESSAGE, a JSON object, to CONNECTION." #<bytecode 0x2d8814c44a59c28>)(#<jsonrpc-process-connection jsonrpc-process-connection-43645c72> :method textDocument/didChange :params (:textDocument (:uri "buffer://%20*Minibuf-1*" :version 4) :contentChanges [(:range (:start (:line 0 :character 0) :end (:line 0 :character 0)) :text "  roles:�")]))
  apply(#f(compiled-function (arg1 &rest rest) "Send MESSAGE, a JSON object, to CONNECTION." #<bytecode 0x2d8814c44a59c28>) #<jsonrpc-process-connection jsonrpc-process-connection-43645c72> (:method textDocument/didChange :params (:textDocument (:uri "buffer://%20*Minibuf-1*" :version 4) :contentChanges [(:range (:start (:line 0 :character 0) :end (:line 0 :character 0)) :text "  roles:�")])))
  jsonrpc-connection-send(#<jsonrpc-process-connection jsonrpc-process-connection-43645c72> :method textDocument/didChange :params (:textDocument (:uri "buffer://%20*Minibuf-1*" :version 4) :contentChanges [(:range (:start (:line 0 :character 0) :end (:line 0 :character 0)) :text "  roles:�")]))
  jsonrpc-notify(#<jsonrpc-process-connection jsonrpc-process-connection-43645c72> textDocument/didChange (:textDocument (:uri "buffer://%20*Minibuf-1*" :version 4) :contentChanges [(:range (:start (:line 0 :character 0) :end (:line 0 :character 0)) :text "  roles:�")]))
  (progn (if (copilot--connection-alivep) nil (copilot--start-agent)) (jsonrpc-notify copilot--connection 'textDocument/didChange (list :textDocument (list :uri (copilot--get-uri) :version copilot--doc-version) :contentChanges content-changes)))
  (let* ((range-start (list :line (- (line-number-at-pos beg) copilot--line-bias) :character (- beg (save-excursion (goto-char beg) (line-beginning-position))))) (range-end (if is-insertion range-start (list :line (- (line-number-at-pos end) copilot--line-bias) :character (- end (save-excursion (goto-char end) (line-beginning-position)))))) (text (if is-insertion (buffer-substring-no-properties beg end) "")) (content-changes (vector (list :range (list :start range-start :end range-end) :text text)))) (setq copilot--doc-version (1+ copilot--doc-version)) (progn (if (copilot--connection-alivep) nil (copilot--start-agent)) (jsonrpc-notify copilot--connection 'textDocument/didChange (list :textDocument (list :uri (copilot--get-uri) :version copilot--doc-version) :contentChanges content-changes))))
  (save-restriction (widen) (let* ((range-start (list :line (- (line-number-at-pos beg) copilot--line-bias) :character (- beg (save-excursion (goto-char beg) (line-beginning-position))))) (range-end (if is-insertion range-start (list :line (- (line-number-at-pos end) copilot--line-bias) :character (- end (save-excursion ... ...))))) (text (if is-insertion (buffer-substring-no-properties beg end) "")) (content-changes (vector (list :range (list :start range-start :end range-end) :text text)))) (setq copilot--doc-version (1+ copilot--doc-version)) (progn (if (copilot--connection-alivep) nil (copilot--start-agent)) (jsonrpc-notify copilot--connection 'textDocument/didChange (list :textDocument (list :uri (copilot--get-uri) :version copilot--doc-version) :contentChanges content-changes)))))
  (progn (save-restriction (widen) (let* ((range-start (list :line (- (line-number-at-pos beg) copilot--line-bias) :character (- beg (save-excursion ... ...)))) (range-end (if is-insertion range-start (list :line (- ... copilot--line-bias) :character (- end ...)))) (text (if is-insertion (buffer-substring-no-properties beg end) "")) (content-changes (vector (list :range (list :start range-start :end range-end) :text text)))) (setq copilot--doc-version (1+ copilot--doc-version)) (progn (if (copilot--connection-alivep) nil (copilot--start-agent)) (jsonrpc-notify copilot--connection 'textDocument/didChange (list :textDocument (list :uri (copilot--get-uri) :version copilot--doc-version) :contentChanges content-changes))))))
  (if (or is-insertion is-deletion) (progn (save-restriction (widen) (let* ((range-start (list :line (- ... copilot--line-bias) :character (- beg ...))) (range-end (if is-insertion range-start (list :line ... :character ...))) (text (if is-insertion (buffer-substring-no-properties beg end) "")) (content-changes (vector (list :range ... :text text)))) (setq copilot--doc-version (1+ copilot--doc-version)) (progn (if (copilot--connection-alivep) nil (copilot--start-agent)) (jsonrpc-notify copilot--connection 'textDocument/didChange (list :textDocument (list :uri ... :version copilot--doc-version) :contentChanges content-changes)))))))
  (let* ((is-before-change (eq chars-replaced nil)) (is-after-change (not is-before-change)) (is-insertion (and is-after-change (not (equal beg end)))) (is-deletion (and is-before-change (not (equal beg end))))) (if (or is-insertion is-deletion) (progn (save-restriction (widen) (let* ((range-start (list :line ... :character ...)) (range-end (if is-insertion range-start ...)) (text (if is-insertion ... "")) (content-changes (vector ...))) (setq copilot--doc-version (1+ copilot--doc-version)) (progn (if (copilot--connection-alivep) nil (copilot--start-agent)) (jsonrpc-notify copilot--connection 'textDocument/didChange (list :textDocument ... :contentChanges content-changes))))))))
  copilot--on-doc-change(13 22 0)
  vertico-insert()
  vertico-exit(nil)
  funcall-interactively(vertico-exit nil)
  command-execute(vertico-exit)

@zerolfx
Copy link
Collaborator

zerolfx commented Mar 25, 2024

It is caused by:

  1. copilot-mode is enabled in your mini buffer.
  2. There is a non-utf8 character in your mini buffer.

To solve the problem, you may want to disable global-copilot-mode and enable copilot-mode only on necessary modes or buffers.

See also #226

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

No branches or pull requests

2 participants