From: João Távora Date: Thu, 27 Jun 2019 16:55:05 +0000 (+0100) Subject: Leniently handle invalid positions sent by some servers X-Git-Tag: emacs-29.0.90~1616^2~524^2~4^2~325 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=8f80ae14559389ae49843efb98bbb4d5ef09cf41;p=emacs.git Leniently handle invalid positions sent by some servers * eglot.el (eglot--lsp-position-to-point): Leniently squash invalid character positions to 0. GitHub-reference: fix https://github.com/joaotavora/eglot/issues/273 --- diff --git a/lisp/progmodes/eglot.el b/lisp/progmodes/eglot.el index ca637238810..d4705551f47 100644 --- a/lisp/progmodes/eglot.el +++ b/lisp/progmodes/eglot.el @@ -1020,8 +1020,14 @@ If optional MARKER, return a marker instead" (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)) - (funcall eglot-move-to-column-function (plist-get pos-plist :character)))) + (let ((tab-width 1) + (col (plist-get pos-plist :character))) + (unless (wholenump col) + (eglot--warn + :eglot "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)