GNU bug report logs -
#61726
[PATCH] Eglot: Support positionEncoding capability
Previous Next
Reported by: Augusto Stoffel <arstoffel <at> gmail.com>
Date: Thu, 23 Feb 2023 08:06:01 UTC
Severity: normal
Tags: patch
Done: João Távora <joaotavora <at> gmail.com>
Bug is archived. No further changes may be made.
Full log
Message #89 received at 61726 <at> debbugs.gnu.org (full text, mbox):
On Fri, Feb 24, 2023 at 11:38 AM Eli Zaretskii <eliz <at> gnu.org> wrote:
> > `eglot-lsp-abiding-column' allocates a new string!
>
> If that is a concern, eglot.el could use a private temporary buffer
> into which the encoded text is inserted, eliminating the need to call
> 'length'. The impact of that in performance should be measured, of
> course, to make sure it doesn't make code slower; it will definitely
> improve the GC pressure aspect.
Indeed, maybe something like this (untested):
diff --git a/lisp/progmodes/eglot.el b/lisp/progmodes/eglot.el
index e20d209332d..78e0f9c1f0c 100644
--- a/lisp/progmodes/eglot.el
+++ b/lisp/progmodes/eglot.el
@@ -1454,11 +1454,15 @@ eglot-current-column-function
(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))
- ;; Fix github#860
- (min (point) (point-max)) 'utf-16 t))
- 2)
- 2))
+ (let ((measure (with-current-buffer (get-buffer-create "
*eglot-utf16-measure*")
+ (erase-buffer)
+ (current-buffer))))
+ (/ (- (encode-coding-region (or lbp (line-beginning-position))
+ ;; Fix github#860
+ (min (point) (point-max)) 'utf-16
+ measure)
+ 2)
+ 2)))
(defun eglot--pos-to-lsp-position (&optional pos)
"Convert point POS to LSP position."
This bug report was last modified 2 years and 137 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.