Replies: 3 comments 4 replies
-
Send this as a patch to [email protected] |
Beta Was this translation helpful? Give feedback.
-
What happens when the |
Beta Was this translation helpful? Give feedback.
-
Thanks; reported at https://debbugs.gnu.org/cgi/bugreport.cgi?bug=70193. |
Beta Was this translation helpful? Give feedback.
-
The LSP showDocument downcall opens the designated file, moves the cursor to the designated position, and raises the frame. One other thing it could do to make it easier to see where the cursor is would be to
recenter
the buffer.The required change is this:
(cl-defmethod eglot-handle-request (_server (_method (eql window/showDocument)) &key uri external takeFocus selection) "Handle request window/showDocument." (let ((success t) (filename)) (cond ((eq external t) (browse-url uri)) ((file-readable-p (setq filename (eglot-uri-to-path uri))) ;; Use run-with-timer to avoid nested client requests like the ;; "synchronous imenu" floated in bug#62116 presumably caused by ;; which-func-mode. (run-with-timer 0 nil (lambda () (with-current-buffer (find-file-noselect filename) (cond (takeFocus (pop-to-buffer (current-buffer)) (select-frame-set-input-focus (selected-frame))) ((display-buffer (current-buffer)))) (when selection (pcase-let ((`(,beg . ,end) (eglot-range-region selection))) ;; FIXME: it is very naughty to use someone else's `--' ;; function, but `xref--goto-char' happens to have ;; exactly the semantics we want vis-a-vis widening. (xref--goto-char beg) + (recenter) (pulse-momentary-highlight-region beg end 'highlight))))))) (t (setq success :json-false))) `(:success ,success)))
I have tested it locally and it works nicely. Can we merge it?
Beta Was this translation helpful? Give feedback.
All reactions