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

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

[elpa] externals/eglot 31fcd91 03/45: Handle case when diagnostic :chara


From: João Távora
Subject: [elpa] externals/eglot 31fcd91 03/45: Handle case when diagnostic :character is out of range
Date: Thu, 22 Nov 2018 19:15:26 -0500 (EST)

branch: externals/eglot
commit 31fcd91f4f056f7d46e5ca5e168b9ec94023d324
Author: Michał K <address@hidden>
Commit: Michał Krzywkowski <address@hidden>

    Handle case when diagnostic :character is out of range
    
    * eglot.el (eglot-handle-notification): Don't error out when
      flymake-diag-region returns nil.
---
 eglot.el | 23 +++++++++++++++--------
 1 file changed, 15 insertions(+), 8 deletions(-)

diff --git a/eglot.el b/eglot.el
index 8014024..b25d8b9 100644
--- a/eglot.el
+++ b/eglot.el
@@ -1080,14 +1080,21 @@ COMMAND is a symbol naming the command."
                        ((`(,beg . ,end) (eglot--range-region range)))
                      ;; Fallback to `flymake-diag-region' if server
                      ;; botched the range
-                     (if (= beg end)
-                         (let* ((st (plist-get range :start))
-                                (diag-region
-                                 (flymake-diag-region
-                                  (current-buffer) (1+ (plist-get st :line))
-                                  (plist-get st :character))))
-                           (setq beg (car diag-region)
-                                 end (cdr diag-region))))
+                     (when (= beg end)
+                       (if-let* ((st (plist-get range :start))
+                                 (diag-region
+                                  (flymake-diag-region
+                                   (current-buffer) (1+ (plist-get st :line))
+                                   (plist-get st :character))))
+                           (setq beg (car diag-region) end (cdr diag-region))
+                         (eglot--widening
+                          (goto-char (point-min))
+                          (setq beg
+                                (point-at-bol
+                                 (1+ (plist-get (plist-get range :start) 
:line))))
+                          (setq end
+                                (point-at-eol
+                                 (1+ (plist-get (plist-get range :end) 
:line)))))))
                      (eglot--make-diag (current-buffer) beg end
                                        (cond ((<= sev 1) 'eglot-error)
                                              ((= sev 2)  'eglot-warning)



reply via email to

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