Function: eglot--virtual-pos-to-lsp-position
eglot--virtual-pos-to-lsp-position is a byte-compiled function defined
in eglot.el.gz.
Signature
(eglot--virtual-pos-to-lsp-position POS STRING)
Documentation
Return the LSP position at the end of STRING if it were inserted at POS.
Source Code
;; Defined in /usr/src/emacs/lisp/progmodes/eglot.el.gz
(defun eglot--virtual-pos-to-lsp-position (pos string)
"Return the LSP position at the end of STRING if it were inserted at POS."
(eglot--widening
(goto-char pos)
(forward-line 0)
;; LSP line is zero-origin; Emacs is one-origin.
(let ((posline (1- (line-number-at-pos nil t)))
(linebeg (buffer-substring (point) pos))
(colfun eglot-current-linepos-function))
;; Use a temp buffer because:
;; - I don't know of a fast way to count newlines in a string.
;; - We currently don't have `eglot-current-linepos-function' for strings.
(with-temp-buffer
(insert linebeg string)
(goto-char (point-max))
(list :line (+ posline (1- (line-number-at-pos nil t)))
:character (funcall colfun))))))