From: Michal Krzywkowski Date: Sat, 8 Sep 2018 22:24:49 +0000 (+0200) Subject: Handle case when diagnostic :character is out of range X-Git-Tag: emacs-29.0.90~1616^2~524^2~4^2~424^2 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=3d9a6f1e79e76bd69c3f3ada4d964233d16730fb;p=emacs.git Handle case when diagnostic :character is out of range * eglot.el (eglot-handle-notification): Don't error out when flymake-diag-region returns nil. --- diff --git a/lisp/progmodes/eglot.el b/lisp/progmodes/eglot.el index 8014024ecd8..b25d8b90df4 100644 --- a/lisp/progmodes/eglot.el +++ b/lisp/progmodes/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)