Skip to content

Commit

Permalink
Simplify a bit of code
Browse files Browse the repository at this point in the history
Co-authored-by: João Távora <joaotavora@gmail.com>

* eglot.el (eglot-move-to-lsp-abiding-column): use
already existing function to refer to lsp-abiding-column

GitHub-reference: close joaotavora/eglot#397
  • Loading branch information
theothornhill authored and joaotavora committed Apr 16, 2020
1 parent 1c2dc32 commit 6bfa6e2
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions lisp/progmodes/eglot.el
Original file line number Diff line number Diff line change
Expand Up @@ -1012,9 +1012,10 @@ fully LSP-compliant servers, this should be set to
`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))
Expand Down Expand Up @@ -1057,9 +1058,7 @@ be set to `eglot-move-to-lsp-abiding-column' (the default), and
(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))
Expand Down

0 comments on commit 6bfa6e2

Please sign in to comment.