`eglot-lsp-abiding-column' (the default), and
`eglot-current-column' for all others.")
-(defun eglot-lsp-abiding-column ()
- "Calculate current COLUMN as defined by the LSP spec."
- (/ (- (length (encode-coding-region (line-beginning-position)
+(defun eglot-lsp-abiding-column (&optional lbp)
+ "Calculate current COLUMN as defined by the LSP spec.
+LBP defaults to `line-beginning-position'."
+ (/ (- (length (encode-coding-region (or lbp (line-beginning-position))
(point) 'utf-16 t))
2)
2))
(narrow-to-region lbp (line-end-position))
(move-to-column column)
for diff = (- column
- (/ (- (length (encode-coding-region lbp (point) 'utf-16 t))
- 2)
- 2))
+ (eglot-lsp-abiding-column lbp))
until (zerop diff)
do (condition-case eob-err
(forward-char (/ (if (> diff 0) (1+ diff) (1- diff)) 2))