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.77k stars 882 forks source link

`lsp-lens-mode` affects `goto-line` #3329

Open peterbecich opened 2 years ago

peterbecich commented 2 years ago

Thank you for the bug report

Bug description

lsp-lens-mode appears to change the way the cursor is placed on certain lines. This only occurs for lines which are preceded by a multi-line Lens. I have provided one example of the bug and three non-examples.

Without knowing anything about how Lenses are rendered, I'm guessing this happens because a multi-line Lens occupies the position of a character.

I suspect this is a limitation of Emacs and cannot be improved.

Thank you

Non-example M-x goto-line 31: the cursor is placed correctly goto_line_31

Another non-example M-x goto-line 32: again, the cursor is placed correctly goto_line_32

Example M-x goto-line 33: the cursor is placed at the top of the lens belonging to line 32. Emacs thinks this position is Line 33, Column 0. goto_line_33

Clicking on line 33, column 0 also places the cursor in that incorrect position. But clicking on line 33, column 1 places the cursor correctly: line_33_column_2

Another non-example M-x goto-line 35: the cursor is placed correctly. This shows that lines which are not preceded by a multi-line lens are unaffected. goto_line_35

These were produced with lsp-start-plain.

Steps to reproduce

Use display-line-numbers-mode and lsp-lens-mode. Begin an LSP session which has multi-line Lenses.

M-x goto-line to a line that follows a multi-line lens. Or click on the first character of a line that follows a multi-line lens.

This file is one example: https://github.com/peterbecich/servant-ekg/blob/6dc27930c34f38ee391a1d4d57dc436438abddd0/lib/Servant/Ekg.hs#L30

Expected behavior

I think the placement of the cursor should match the line numbers on the fringe.

Which Language Server did you use?

lsp-haskell and Haskell Language Server installed with ghcup https://www.haskell.org/ghcup/

OS

Linux

Error callstack

No response

Anything else?

lsp-mode 20220124.1546

JonathanReeve commented 2 years ago

I'm seeing this issue, too, and I'll add that multi-line code lenses break scrolling completely: scrolling with the mouse, or scrolling with the keyboard (pgup / pgdown).