]> git.eshelyaron.com Git - emacs.git/commitdiff
Leniently handle invalid positions sent by some servers
authorJoão Távora <joaotavora@gmail.com>
Thu, 27 Jun 2019 16:55:05 +0000 (17:55 +0100)
committerJoão Távora <joaotavora@gmail.com>
Thu, 27 Jun 2019 16:55:33 +0000 (17:55 +0100)
* eglot.el (eglot--lsp-position-to-point): Leniently squash
invalid character positions to 0.

GitHub-reference: fix https://github.com/joaotavora/eglot/issues/273

lisp/progmodes/eglot.el

index ca6372388105f3a2df899801d495158b63961b90..d4705551f470cb307a42f0ce0a1534c8304c204f 100644 (file)
@@ -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)