From e6a801ccf6f745d149306d2afaaa4b3d313415e9 Mon Sep 17 00:00:00 2001 From: Michal Krzywkowski Date: Sat, 28 Jul 2018 19:14:02 +0200 Subject: [PATCH] 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 --- lisp/progmodes/eglot.el | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) 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. -- 2.39.2