branch: externals/eglot commit 04ef0558a1a4c64287f7c5b77b8c68df095a8b3b Author: João Távora <joaotav...@gmail.com> Commit: João Távora <joaotav...@gmail.com>
Close #27: empty ranges are valid in LSP The previous hack in eglot--range-region, designed to appease cquery's occasional practice of publishing diagnostics with empty regions, was moved to the proper notification handler. Reported by mkcms <k.mic...@zoho.com>. * eglot.el (eglot--range-region): Allow empty ranges, which are allowed in LSP. (eglot-handle-notification :textDocument/publishDiagnostics): Maybe fallback to flymake-diag-region here. --- eglot.el | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/eglot.el b/eglot.el index 2fdf433..f4a03da 100644 --- a/eglot.el +++ b/eglot.el @@ -896,10 +896,7 @@ If optional MARKERS, make markers." (let* ((st (plist-get range :start)) (beg (eglot--lsp-position-to-point st markers)) (end (eglot--lsp-position-to-point (plist-get range :end) markers))) - ;; Fallback to `flymake-diag-region' if server botched the range - (if (/= beg end) (cons beg end) (flymake-diag-region - (current-buffer) (plist-get st :line) - (1- (plist-get st :character)))))) + (cons beg end))) ;;; Minor modes @@ -1125,7 +1122,18 @@ Don't leave this function with the server still running." _code source message) diag-spec (setq message (concat source ": " message)) - (pcase-let ((`(,beg . ,end) (eglot--range-region range))) + (pcase-let + ((`(,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) (plist-get st :line) + (1- (plist-get st :character))))) + (setq beg (car diag-region) + end (cdr diag-region)))) (eglot--make-diag (current-buffer) beg end (cond ((<= sev 1) 'eglot-error) ((= sev 2) 'eglot-warning)