]> git.eshelyaron.com Git - emacs.git/commitdiff
Treat tab characters as 1 column wide in position conversion functions
authorMichal Krzywkowski <k.michal@zoho.com>
Mon, 19 Nov 2018 20:22:14 +0000 (21:22 +0100)
committerMichal Krzywkowski <k.michal@zoho.com>
Mon, 19 Nov 2018 20:26:39 +0000 (21:26 +0100)
Fixes https://github.com/joaotavora/eglot/issues/158.

* eglot.el (eglot--pos-to-lsp-position): Call
  eglot-current-column-function with tab-width bound to 1.
(eglot--lsp-position-to-point): Call eglot-move-to-column-function
with tab-width bound to 1.

lisp/progmodes/eglot.el

index 3ba1b87d8077d67f6ffd7cf9e6cbeb6dd85d2954..d9c1c3ab97e531e4c08453b69e31b3c7162d198f 100644 (file)
@@ -743,7 +743,8 @@ for all others.")
   (eglot--widening
    (list :line (1- (line-number-at-pos pos t)) ; F!@&#$CKING OFF-BY-ONE
          :character (progn (when pos (goto-char pos))
-                           (funcall eglot-current-column-function)))))
+                           (let ((tab-width 1))
+                             (funcall eglot-current-column-function))))))
 
 (defvar eglot-move-to-column-function #'move-to-column
   "Function to move to a column reported by the LSP server.
@@ -778,7 +779,8 @@ If optional MARKER, return a marker instead"
     (forward-line (min most-positive-fixnum
                        (plist-get pos-plist :line)))
     (unless (eobp) ;; if line was excessive leave point at eob
-      (funcall eglot-move-to-column-function (plist-get pos-plist :character)))
+      (let ((tab-width 1))
+        (funcall eglot-move-to-column-function (plist-get pos-plist :character))))
     (if marker (copy-marker (point-marker)) (point))))
 
 (defun eglot--path-to-uri (path)