manateelazycat / lsp-bridge

A blazingly fast LSP client for Emacs
GNU General Public License v3.0
1.45k stars 208 forks source link

lsp-bridge-code-action picks always the same code action, no matter the user input #1045

Closed kuba-orlik closed 1 month ago

kuba-orlik commented 1 month ago

When I run lsp-bridge-code-action, it asks me to choose which action I want to run.

No matter which option I chose, it always runs the "move to a separate file" code action. You can see a recording of this issue here:

https://asciinema.org/a/z8yVE3KVktEzdaMzK818hF2VC

I've been using this sample repository that includes a minimal emacs config to reproduce this issue:

https://github.com/kuba-orlik/lsp-bridge-code-action-repro

My lsp-bridge config is

(use-package lsp-bridge
  :defer t
  :straight
  '(lsp-bridge
    :type git :host github :repo "manateelazycat/lsp-bridge"
    :files (:defaults "*.el" "*.py" "acm" "core" "langserver" "multiserver" "resources")
    :build (:not compile))

  :bind (("M-." . lsp-bridge-find-def)
     ("M-," . lsp-bridge-find-def-return)
     ("C-M-." . lsp-bridge-peek)
     ("C-c c a" . lsp-bridge-code-action)
     ("M-?" . lsp-bridge-find-references)
     ("C-c ! n" . lsp-bridge-diagnostic-jump-next)
     ("C-c ! p" . lsp-bridge-diagnostic-jump-prev)
     ("C-c c r" . lsp-bridge-rename)
     ("C-h ." . lsp-bridge-popup-documentation)
     ("C-h >" . lsp-bridge-show-documentation)
     )
  :init
  (setq lsp-bridge-enable-log t)
  (setq lsp-bridge-python-command "python3")

  ;; otherwise it freezes emacs see https://github.com/manateelazycat/lsp-bridge/issues/711
  (setq lsp-bridge-code-action-enable-popup-menu nil)

  (setq  lsp-bridge-enable-completion-in-string t)

  :hook ((typescript-ts-mode js-ts-mode web-mode html-mode css-mode scss-mode json-mode yaml-mode sh-mode shell-script-mode bash-ts-mode dockerfile-mode markdown-mode qml-mode emacs-lisp-mode tsx-ts-mode) . lsp-bridge-mode)  

  )

I'm using Linux

Snooping into what lsp-bridge-epc-net-send is sending, I can confirm that the chosen action is not actually sent to the epc

00007e(call 1305 execute_command ("/home/kuba/Downloads/lsp-error-repro/src/index.ts" "typescript" "_typescript.applyRefactoring"))

However, lsp-bridge seems to fill in the missing data, and I guess it fills it with the first action, instead of what the user actually chose?

--- [14:41:26.542474] Send workspace/executeCommand request (49005) to 'vscode-eslint-language-server' for project lsp-error-repro
{
   "id": 49005,
   "method": "workspace/executeCommand",
   "params": {
      "command": "_typescript.applyRefactoring",
      "arguments": [
         {
            "file": "/home/kuba/Downloads/lsp-error-repro/src/index.ts",
            "startLine": 5,
            "startOffset": 27,
            "endLine": 5,
            "endOffset": 27,
            "refactor": "Move to a new file",
            "action": "Move to a new file"
         }
      ]
   },
   "message_type": "request",
   "jsonrpc": "2.0"
}
manateelazycat commented 1 month ago

https://github.com/manateelazycat/lsp-bridge/commit/226fc1b90be25a6bcdc6f6aafbad8c8a18c2ecfa

Has fixed, thanks for report.

kuba-orlik commented 1 month ago

Thanks! <3