You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I think there's an off-by-one error in the publishDiagnostics. When a server-reported diagnostic has an empty range (the same value for begin and end) the logic falls back to flymake-diag-region, but it forgets to convert the 0-based LSP character index to the 1-based column number conventionally used by Emacs. (It also doesn't transcode UTF-16 to code points, but that's ok.)
If I'm right, the fix is this:
(cl-defmethod eglot-handle-notification
(_server (_method (eql textDocument/publishDiagnostics)) &key uri diagnostics
&allow-other-keys) ; FIXME: doesn't respect `eglot-strict-mode'
"Handle notification publishDiagnostics."
...
;; Fallback to `flymake-diag-region' if server
;; botched the range
(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))))+ (1+ (plist-get st :character)))))
(setq beg (car diag-region) end (cdr diag-region))
(eglot--widening
(goto-char (point-min))
(setq beg
(eglot--bol
(1+ (plist-get (plist-get range :start) :line))))
(setq end
(line-end-position
(1+ (plist-get (plist-get range :end) :line)))))))
...
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I think there's an off-by-one error in the publishDiagnostics. When a server-reported diagnostic has an empty range (the same value for begin and end) the logic falls back to flymake-diag-region, but it forgets to convert the 0-based LSP character index to the 1-based column number conventionally used by Emacs. (It also doesn't transcode UTF-16 to code points, but that's ok.)
If I'm right, the fix is this:
Should I send a patch?
Beta Was this translation helpful? Give feedback.
All reactions