Function: eglot--lsp-position-to-point

eglot--lsp-position-to-point is a byte-compiled function defined in eglot.el.gz.

Signature

(eglot--lsp-position-to-point POS-PLIST &optional MARKER)

Documentation

Convert LSP position POS-PLIST to Emacs point.

If optional MARKER, return a marker instead

Source Code

;; Defined in /usr/src/emacs/lisp/progmodes/eglot.el.gz
(defun eglot--lsp-position-to-point (pos-plist &optional marker)
  "Convert LSP position POS-PLIST to Emacs point.
If optional MARKER, return a marker instead"
  (save-excursion
    (save-restriction
      (widen)
      (goto-char (point-min))
      (forward-line (min most-positive-fixnum
                         (plist-get pos-plist :line)))
      (unless (eobp) ;; if line was excessive leave point at eob
        (let ((col (plist-get pos-plist :character)))
          (unless (wholenump col)
            (eglot--warn
             "Caution: LSP server sent invalid character position %s. Using 0 instead."
             col)
            (setq col 0))
          (funcall eglot-move-to-linepos-function col)))
      (if marker (copy-marker (point-marker)) (point)))))