emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/elpa 3634402 36/71: Fix #479: correctly place diagnosti


From: João Távora
Subject: [elpa] externals/elpa 3634402 36/71: Fix #479: correctly place diagnostics in narrowed buffers
Date: Wed, 16 Dec 2020 11:42:20 -0500 (EST)

branch: externals/elpa
commit 363440249b091f229672727841d63250f970ea2e
Author: João Távora <joaotavora@gmail.com>
Commit: João Távora <joaotavora@gmail.com>

    Fix #479: correctly place diagnostics in narrowed buffers
    
    * eglot.el (eglot--lsp-position-to-point)
    (eglot-handle-notification): save-restriction and widen
---
 eglot.el | 44 ++++++++++++++++++++++++--------------------
 1 file changed, 24 insertions(+), 20 deletions(-)

diff --git a/eglot.el b/eglot.el
index f3501cb..21a2496 100644
--- a/eglot.el
+++ b/eglot.el
@@ -1118,19 +1118,21 @@ be set to `eglot-move-to-lsp-abiding-column' (the 
default), and
   "Convert LSP position POS-PLIST to Emacs point.
 If optional MARKER, return a marker instead"
   (save-excursion
-    (goto-char (point-min))
-    (forward-line (min most-positive-fixnum
-                       (plist-get pos-plist :line)))
-    (unless (eobp) ;; if line was excessive leave point at eob
-      (let ((tab-width 1)
-            (col (plist-get pos-plist :character)))
-        (unless (wholenump col)
-          (eglot--warn
-           "Caution: LSP server sent invalid character position %s. Using 0 
instead."
-           col)
-          (setq col 0))
-        (funcall eglot-move-to-column-function col)))
-    (if marker (copy-marker (point-marker)) (point))))
+    (save-restriction
+      (widen)
+      (goto-char (point-min))
+      (forward-line (min most-positive-fixnum
+                         (plist-get pos-plist :line)))
+      (unless (eobp) ;; if line was excessive leave point at eob
+        (let ((tab-width 1)
+              (col (plist-get pos-plist :character)))
+          (unless (wholenump col)
+            (eglot--warn
+             "Caution: LSP server sent invalid character position %s. Using 0 
instead."
+             col)
+            (setq col 0))
+          (funcall eglot-move-to-column-function col)))
+      (if marker (copy-marker (point-marker)) (point)))))
 
 (defun eglot--path-to-uri (path)
   "URIfy PATH."
@@ -1585,13 +1587,15 @@ COMMAND is a symbol naming the command."
                                        message `((eglot-lsp-diag . 
,diag-spec)))))
          into diags
          finally (cond ((and flymake-mode eglot--current-flymake-report-fn)
-                        (funcall eglot--current-flymake-report-fn diags
-                                 ;; If the buffer hasn't changed since last
-                                 ;; call to the report function, flymake won't
-                                 ;; delete old diagnostics.  Using :region
-                                 ;; keyword forces flymake to delete
-                                 ;; them (github#159).
-                                 :region (cons (point-min) (point-max)))
+                        (save-restriction
+                          (widen)
+                          (funcall eglot--current-flymake-report-fn diags
+                                   ;; If the buffer hasn't changed since last
+                                   ;; call to the report function, flymake 
won't
+                                   ;; delete old diagnostics.  Using :region
+                                   ;; keyword forces flymake to delete
+                                   ;; them (github#159).
+                                   :region (cons (point-min) (point-max))))
                         (setq eglot--unreported-diagnostics nil))
                        (t
                         (setq eglot--unreported-diagnostics (cons t diags))))))



reply via email to

[Prev in Thread] Current Thread [Next in Thread]