emacs-lsp / lsp-mode

Emacs client/library for the Language Server Protocol
https://emacs-lsp.github.io/lsp-mode
GNU General Public License v3.0
4.75k stars 872 forks source link

multiple errors on same line confuse code actions #3442

Closed eli-tziperman closed 10 months ago

eli-tziperman commented 2 years ago

Thank you for the bug report

Bug description

I am using lsp-grammarly. With a sentence like:

Here is a santence with moltiple mistakees.

if I click on the second or third mistakes, the code actions offered (either via sideline or code-actions right-mouse-click menu item) always belong to the first error. If I write the sentence instead as:

Here is a santence with moltiple mistakees.

the problem disappears. Happy to provide additional information.

Steps to reproduce

requires lsp-grammarly

Expected behavior

clicking on a given error should show code actions for that error, not others

Which Language Server did you use?

text file

OS

MacOS

Error callstack

no error messages

Anything else?

that's it

yyoncho commented 2 years ago

That is true, we pass all errors as context since the beginning of the project. We should fix that

eli-tziperman commented 2 years ago

Good to know... I would love to help with testing.

eli-tziperman commented 10 months ago

Wondering (as a user) if there is something one could do to make this fix happen...?

yyoncho commented 10 months ago

PR at https://github.com/emacs-lsp/lsp-mode/pull/4205

eli-tziperman commented 10 months ago

thanks for doing this! I am assuming that's in the latest elpa/melpa. when I try this on a small text file with lsp-grammarly I get some error messages:

LSP :: Connected to [grammarly-ls:73015/starting /Users/eli]. Starting new Ispell process /opt/local/bin/aspell with default dictionary...done Fill column set to 8192 (was 70) LSP :: grammarly-ls:73015 initialized successfully in folders: (/Users/eli) error in process filter: Unable to find Content-Length header. [2 times] Error running timer ‘lsp--on-idle’: (wrong-type-argument hash-table-p (:line 0 :character 0)) [2 times] Error running timer ‘lsp--on-idle’: (wrong-type-argument hash-table-p (:line 1 :character 0)) Error running timer ‘lsp--on-idle’: (wrong-type-argument hash-table-p (:line 0 :character 100)) [4 times] Error running timer ‘lsp--on-idle’: (wrong-type-argument hash-table-p (:line 0 :character 30)) [2 times]

and it seems that the action suggested is not necessarily that where the cursor is...? here is a snapshot:

image
yyoncho commented 10 months ago

I am on it.

yyoncho commented 10 months ago

Pushed a fix.

eli-tziperman commented 10 months ago

that's great progress, the timer error is gone...!

I still get this: error in process filter: Unable to find Content-Length header. [2 times] error in process filter: Args out of range: "ontent-Length: 110 {\"jsonrpc\":\"2.0\",\"method\":\"window/logMessage\",\"params\":{\"type\":4,\"message\":\"idle file:///Users/XX/asfd.txt\"}}Content-Length: 109 {\"jsonrpc\":\"2.0\",\"method\":\"$/onDocumentStatus\",\"params\":{\"uri\":\"file:///Users/XX/asfd.txt\",\"status\":\"idle\"}}Content-Length: 762

and the lsp-ui suggestions in orange as in the above snapshot still seem to point to the wrong error.

yyoncho commented 10 months ago

@eli-tziperman I have reverted https://github.com/emacs-lsp/lsp-mode/pull/4213

I would appreciate if you can help me with testing some versions of the original PR so we can see what is happening. What emacs version do you use?

eli-tziperman commented 10 months ago

I would love to try. I use: GNU Emacs 29.1 (build 1, x86_64-apple-darwin21.6.0, Carbon Version 165 AppKit 2113.6) of 2023-08-08

yyoncho commented 10 months ago

@eli-tziperman can you test this: https://github.com/yyoncho/lsp-mode/commit/fd9214ae75e19de0c6484c93b85f15bf92a0bfe5 ?

eli-tziperman commented 10 months ago

OK, I am embarrassed to ask, but how do I install this? I downloaded a zip file from GitHub, what's next?

On Thu, Nov 2, 2023 at 4:40 AM Ivan Yonchovski @.***> wrote:

@eli-tziperman https://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_eli-2Dtziperman&d=DwMCaQ&c=WO-RGvefibhHBZq3fL85hQ&r=KYyaxH1lmVR4t1SuGeFOBHWryGg1z4AMCHouqjrz7Hg&m=js5QNuzAuvlCuA8m_xb9TrzBaSToEKxA93DUUYH_m017IUifk7wGDGZOAzivynux&s=SGJqNU8l8CsvaVWNSp9Ur-ne8GewlFFUTdda50ggwiM&e= can you test this: @.*** https://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_yyoncho_lsp-2Dmode_commit_fd9214ae75e19de0c6484c93b85f15bf92a0bfe5&d=DwMCaQ&c=WO-RGvefibhHBZq3fL85hQ&r=KYyaxH1lmVR4t1SuGeFOBHWryGg1z4AMCHouqjrz7Hg&m=js5QNuzAuvlCuA8m_xb9TrzBaSToEKxA93DUUYH_m017IUifk7wGDGZOAzivynux&s=RlsZ58OWcfq99pZ7S5btLesEw5lFTns03Shl_t3HCDA&e= ?

— Reply to this email directly, view it on GitHub https://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_emacs-2Dlsp_lsp-2Dmode_issues_3442-23issuecomment-2D1790293226&d=DwMCaQ&c=WO-RGvefibhHBZq3fL85hQ&r=KYyaxH1lmVR4t1SuGeFOBHWryGg1z4AMCHouqjrz7Hg&m=js5QNuzAuvlCuA8m_xb9TrzBaSToEKxA93DUUYH_m017IUifk7wGDGZOAzivynux&s=PZUZtg1SW2imSxzs3ZNBDu67AxL1tD3CyaMUstAIOz4&e=, or unsubscribe https://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_notifications_unsubscribe-2Dauth_ADLJH53IHTS5MSD36BOD62DYCNL7ZAVCNFSM5SMR2ZUKU5DIOJSWCZC7NNSXTN2JONZXKZKDN5WW2ZLOOQ5TCNZZGAZDSMZSGI3A&d=DwMCaQ&c=WO-RGvefibhHBZq3fL85hQ&r=KYyaxH1lmVR4t1SuGeFOBHWryGg1z4AMCHouqjrz7Hg&m=js5QNuzAuvlCuA8m_xb9TrzBaSToEKxA93DUUYH_m017IUifk7wGDGZOAzivynux&s=tvU3uyxca4aVOT2Iy7S9MnLl9TkCnwTotu0dC2GuT3A&e= . You are receiving this because you were mentioned.Message ID: @.***>

yyoncho commented 10 months ago

No worries. One way to install it is to use https://github.com/quelpa/quelpa#overview (you can specify the commit to be used). Here it is how you can do that in clean env:

(require 'package)

(setq debug-on-error t
      no-byte-compile t
      byte-compile-warnings nil
      inhibit-startup-screen t
      package-archives '(("melpa" . "https://melpa.org/packages/")
                         ("gnu" . "https://elpa.gnu.org/packages/"))
      package-user-dir (make-temp-file "lsp-tmp-elpa")
      custom-file (expand-file-name "custom.el" package-user-dir))

(delete-file package-user-dir)

(package-initialize)
(package-refresh-contents)
(package-install 'quelpa)
(quelpa
 '(lsp-mode :repo "yyoncho/lsp-mode"
            :fetcher github
            :commit "fd9214ae75e19de0c6484c93b85f15bf92a0bfe5"
            :files ("*.el" "clients/*.el")))
(add-hook 'prog-mode-hook 'lsp)
(add-hook 'kill-emacs-hook `(lambda ()
                              (delete-directory ,package-user-dir t)))

(provide 'lsp-start-plain)
;;; lsp-start-plain.el ends here

And then you can do emacs -q -l lsp-start-plain.el. Or you can delete lsp-mode and put the following lines in your config:

(package-install 'quelpa)
(quelpa
 '(lsp-mode :repo "yyoncho/lsp-mode"
            :fetcher github
            :commit "fd9214ae75e19de0c6484c93b85f15bf92a0bfe5"
            :files ("*.el" "clients/*.el")))
eli-tziperman commented 10 months ago

great, thanks. I think I see progress:

image

so you see that the code actions you get via completion at the bottom are correct. but the ones you get in orange (from lsp-ui?) are not. is this a helpful clue?