From: Michal Krzywkowski Date: Sat, 28 Jul 2018 17:14:02 +0000 (+0200) Subject: Correctly make lsp positions in narrowed buffers X-Git-Tag: emacs-29.0.90~1616^2~524^2~4^2~466 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=e6a801ccf6f745d149306d2afaaa4b3d313415e9;p=emacs.git Correctly make lsp positions in narrowed buffers * eglot.el (eglot--pos-to-lsp-position): Fix return value when narrowing is in effect. GitHub-reference: close https://github.com/joaotavora/eglot/issues/54 --- diff --git a/lisp/progmodes/eglot.el b/lisp/progmodes/eglot.el index 3c01657abb7..fbc6a53db5e 100644 --- a/lisp/progmodes/eglot.el +++ b/lisp/progmodes/eglot.el @@ -597,10 +597,10 @@ CONNECT-ARGS are passed as additional arguments to (defun eglot--pos-to-lsp-position (&optional pos) "Convert point POS to LSP position." - (save-excursion - (list :line (1- (line-number-at-pos pos t)) ; F!@&#$CKING OFF-BY-ONE - :character (- (goto-char (or pos (point))) - (line-beginning-position))))) + (eglot--widening + (list :line (1- (line-number-at-pos pos t)) ; F!@&#$CKING OFF-BY-ONE + :character (- (goto-char (or pos (point))) + (line-beginning-position))))) (defun eglot--lsp-position-to-point (pos-plist &optional marker) "Convert LSP position POS-PLIST to Emacs point.