Open andreyorst opened 2 years ago
Hum, we should probably change lsp-mode to hide lens when narrowing c/c @yyoncho
does it fix itself after changing the text?
I was able to test it - it fixes itself after narrowing and changing the buffer content. So we should refresh the lenses after narowing.
@yyoncho do you know what narrow hook we can watch it?
I'm afraid there's no such hook. However all narrowing commands should use narrow-to-region
, and it is a C function, so it seems to fix the issue it can just be advised:
(define-advice narrow-to-region (:after (&rest _))
(lsp-lens-refresh t))
(define-advice widen (:after (&rest _))
(lsp-lens-refresh t))
This, however, raises another issue, when using indirect narrowing. When I first narrow to an indirect buffer with the advice from above, I get the correct lens in the indirect buffer and no lens in the original buffer:
However, when I focus the original buffer I get this:
I'm not sure how this should be handled
I'm afraid there's no such hook. However all narrowing commands should use
narrow-to-region
, and it is a C function, so it seems to fix the issue it can just be advised:(define-advice narrow-to-region (:after (&rest _)) (lsp-lens-refresh t)) (define-advice widen (:after (&rest _)) (lsp-lens-refresh t))
I've tried this for a day and noticed an extreme CPU usage in the clojure-lsp
process (about 500%). I've not tried other servers, but removing the advices resolved the CPU usage issue, so I think this method is not very good.
it should be (lsp-lens-refresh nil)
and also it should check if the buffer has lens mode enabled.
Thank you for the bug report
lsp-mode
related packages.where
lsp-start-plain.el
can be downloaded here.Bug description
If the buffer is narrowed all lenses below the narrowed region are displayed at the last line.
Steps to reproduce
Open a buffer, and create some variables, so the server could return the lens, for them. Here's an example in Clojure:
Here are the lenses:
Then narrow to defun on
(def a nil)
line:Expected behavior
Only one lens is displayed.
Which Language Server did you use?
clojure-lsp
OS
Linux
Error callstack
No response
Anything else?
No response