manateelazycat / lsp-bridge

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

Duplicate, Using code actions freezes emacs #827

Closed Kenneth-Mata closed 8 months ago

Kenneth-Mata commented 8 months ago

Using the lsp-bridge-code-action while having lsp-bridge-code-action-enable-popup-menu enabled will cause emacs to freeze, it will not respond to keyboard input (but mouse input, at least on wayland) will still work

I tried using this configuration

(setq package-enable-at-startup nil)
(setq straight-check-for-modifications nil)

(defvar bootstrap-version)
(let ((bootstrap-file
       (expand-file-name
        "straight/repos/straight.el/bootstrap.el"
        (or (bound-and-true-p straight-base-dir)
            user-emacs-directory)))
      (bootstrap-version 7))
  (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))

(use-package straight
  :config
  (setopt straight-use-package-by-default t))
(use-package yasnippet :config (yas-global-mode 1))
(use-package yasnippet-snippets)
(use-package markdown-mode)
(use-package lsp-bridge
  :straight '(lsp-bridge :type git :host github :repo "manateelazycat/lsp-bridge"
                         :files (:defaults "*.el" "*.py" "acm" "core" "langserver" "multiserver" "resources")
                         :build (:not compile))
  :init
  (global-lsp-bridge-mode)
  :config
(setopt lsp-bridge-enable-log t)  
(setopt lsp-bridge-python-command "/home/kenneth/.conda/envs/py_env/bin/python"))

Screencast_20240111_181830-1.webm

This is the lsp-bridge buffer after the code action

Screenshot_20240111_182200

It was previously mentioned here

I'm not very knowledgeable in either elisp or python, but i think this is worth mentioning, or disabling the popup by default / removing the option if it doesn't work properly.

Kenneth-Mata commented 8 months ago

Tried with a different language, it also happens with gopls

Screencast_20240111_184822.webm

The lsp-bridge buffer

Screenshot_20240111_185024

manateelazycat commented 8 months ago

can you send example code to me?

Kenneth-Mata commented 8 months ago
#include <stdio.h>
/* ANSI C doesn't require int to be the return of the main function*/
main() {
    float fahr, celsius, upper, lower, step;
    step = 20;
    upper = 500;
    lower = 0;

    fahr = lower;
    printf("%s", "Fahrenheit to Celsius Table\n");
    while (fahr <= upper) {
        celsius = (5.0 / 9.0) * (fahr - 32);
        printf("%6.2d   %9.1f\n" ,fahr, celsius);
        fahr = fahr + step;
    }
}

This is from the C Programming Book 2nd, clangd will highlight that %6.2d should be %6.2f, but freeze after selecting the fix

manateelazycat commented 8 months ago

I used the above code to test locally. The code action ran normally and there was no freezing problem. Please use emacs -Q to load only lsp-bridge for testing to eliminate the influence of other plug-ins.

Kenneth-Mata commented 8 months ago

I'm using --init-directory for the tests

(add-to-list 'load-path "/home/kenneth/.config/emm/lsp-bridge")

(require 'yasnippet)
(yas-global-mode 1)

(require 'lsp-bridge)
(global-lsp-bridge-mode)

(setopt lsp-bridge-enable-log t)
(setq lsp-bridge-python-command "/home/kenneth/.conda/envs/py_env/bin/python")

i tried with this configuration, directly download the lsp-bridge repo and still got the freezing behavior

Screenshot_20240112_122143

I'll try to replicate this behavior on a VM and/or my windows machine

kuba-orlik commented 1 week ago

I can also confirm this behavior. It happens only in graphical mode, not in -nw mode. It seems it has to do more with showing/hiding the action popup than with applying the action itself, as when I C-g to hide the popup, the freeze still occurs. This happens in Wayland and in XOrg. I'm using pgtk emacs

manateelazycat commented 1 week ago

I can also confirm this behavior. It happens only in graphical mode, not in -nw mode. It seems it has to do more with showing/hiding the action popup than with applying the action itself, as when I C-g to hide the popup, the freeze still occurs. This happens in Wayland and in XOrg. I'm using pgtk emacs我也可以确认这种行为。它仅发生在图形模式下,而不发生在-nw模式下。看起来它必须在显示/隐藏操作弹出窗口方面做更多的事情,而不是应用操作本身,因为当我Cg隐藏弹出窗口时,冻结仍然发生。这种情况发生在 Wayland 和 XOrg 中。我正在使用 pgtk emacs

(setq pgtk-wait-for-event-timeout 0)

Will fix your problem?

manateelazycat commented 1 week ago

I can also confirm this behavior. It happens only in graphical mode, not in -nw mode. It seems it has to do more with showing/hiding the action popup than with applying the action itself, as when I C-g to hide the popup, the freeze still occurs. This happens in Wayland and in XOrg. I'm using pgtk emacs我也可以确认这种行为。它仅发生在图形模式下,而不发生在-nw模式下。看起来它必须在显示/隐藏操作弹出窗口方面做更多的事情,而不是应用操作本身,因为当我Cg隐藏弹出窗口时,冻结仍然发生。这种情况发生在 Wayland 和 XOrg 中。我正在使用 pgtk emacs

(setq pgtk-wait-for-event-timeout 0)

Will fix your problem?

@kuba-orlik Can you help to test this solution? Thanks

kuba-orlik commented 1 week ago

I've just tested it and unfortunately it does not solve this problem

manateelazycat commented 1 week ago

It's looks like pgtk branch bug, I haven't use pgtk, can't help you.