emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/eglot 28ecd5d 34/69: Change the default of eglot-move-t


From: João Távora
Subject: [elpa] externals/eglot 28ecd5d 34/69: Change the default of eglot-move-to-column-function
Date: Sun, 20 Oct 2019 08:21:48 -0400 (EDT)

branch: externals/eglot
commit 28ecd5df456fec6113751bd52816095e0be3e651
Author: Felicián Németh <address@hidden>
Commit: Felician Nemeth <Felicián Németh>

    Change the default of eglot-move-to-column-function
    
    Previous default (move-to-column) works on visual columns, the LSP
    specification and the new default (eglot-move-to-column) use "real"
    columns.  Fixes #293 and #297.
    
    * eglot.el (eglot-move-to-column): New function.
    (eglot-move-to-column-function): Use it as default.
---
 eglot.el | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/eglot.el b/eglot.el
index 23d53ed..b87d5bb 100644
--- a/eglot.el
+++ b/eglot.el
@@ -988,7 +988,7 @@ for all others.")
          :character (progn (when pos (goto-char pos))
                            (funcall eglot-current-column-function)))))
 
-(defvar eglot-move-to-column-function #'move-to-column
+(defvar eglot-move-to-column-function #'eglot-move-to-column
   "Function to move to a column reported by the LSP server.
 
 According to the standard, LSP column/character offsets are based
@@ -999,7 +999,16 @@ where X is a multi-byte character, it actually means `b', 
not
 
 For buffers managed by fully LSP-compliant servers, this should
 be set to `eglot-move-to-lsp-abiding-column', and
-`move-to-column' (the default) for all others.")
+`eglot-move-to-column' (the default) for all others.")
+
+(defun eglot-move-to-column (column)
+  "Move to COLUMN without closely following the LSP spec."
+  ;; We cannot use `move-to-column' here, because it moves to *visual*
+  ;; columns, which can be different from LSP columns in case of
+  ;; `whitespace-mode', `prettify-symbols-mode', etc.  (github#296,
+  ;; github#297)
+  (goto-char (min (+ (line-beginning-position) column)
+                  (line-end-position))))
 
 (defun eglot-move-to-lsp-abiding-column (column)
   "Move to COLUMN abiding by the LSP spec."



reply via email to

[Prev in Thread] Current Thread [Next in Thread]