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

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

[nongnu] elpa/go-mode 2d1d33a 407/495: Fix off-by-one in point calculati


From: ELPA Syncer
Subject: [nongnu] elpa/go-mode 2d1d33a 407/495: Fix off-by-one in point calculations
Date: Sat, 7 Aug 2021 09:05:57 -0400 (EDT)

branch: elpa/go-mode
commit 2d1d33aee33a5cc088a8f51057464b7cd738cbdd
Author: Wilfred Hughes <whughes@ahl.com>
Commit: Dominik Honnef <dominik@honnef.co>

    Fix off-by-one in point calculations
    
    Emacs point is 1-indexed rather than 0-indexed. As a result, calling
    godef-jump on the following code:
    
        foo|(bar) // assuming | is point
    
    would find the definition of bar rather than foo.
---
 go-mode.el | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/go-mode.el b/go-mode.el
index e569aa0..f20dc1f 100644
--- a/go-mode.el
+++ b/go-mode.el
@@ -1478,7 +1478,8 @@ description at POINT."
                                "-f"
                                (file-truename (buffer-file-name 
(go--coverage-origin-buffer)))
                                "-o"
-                               (number-to-string (position-bytes point)))
+                               ;; Emacs point and byte positions are 1-indexed.
+                               (number-to-string (1- (position-bytes point))))
           (with-current-buffer outbuf
             (split-string (buffer-substring-no-properties (point-min) 
(point-max)) "\n"))
         (kill-buffer outbuf)))))



reply via email to

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