[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/go-mode 6ac5669 372/495: cmd/guru: emacs: interpret byte o
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/go-mode 6ac5669 372/495: cmd/guru: emacs: interpret byte offsets correctly |
Date: |
Sat, 7 Aug 2021 09:05:50 -0400 (EDT) |
branch: elpa/go-mode
commit 6ac56695d16da5758d1d64d296454124b2e92e11
Author: Dominik Honnef <dominik@honnef.co>
Commit: Dominik Honnef <dominik@honnef.co>
cmd/guru: emacs: interpret byte offsets correctly
Change-Id: Id506c6c0b3f3c585781bfc38df1b665d507a7c33
Reviewed-on: https://go-review.googlesource.com/22019
Reviewed-by: Alan Donovan <adonovan@google.com>
---
guru_import/cmd/guru/go-guru.el | 20 ++++++++++++--------
1 file changed, 12 insertions(+), 8 deletions(-)
diff --git a/guru_import/cmd/guru/go-guru.el b/guru_import/cmd/guru/go-guru.el
index b837de0..c4be257 100644
--- a/guru_import/cmd/guru/go-guru.el
+++ b/guru_import/cmd/guru/go-guru.el
@@ -262,10 +262,14 @@ If BUFFER, return the number of characters in that buffer
instead."
(string-bytes (buffer-substring (point-min)
(point-max)))))
-;; FIXME(dominikh): go-guru--goto-pos-no-file and go-guru--goto-pos
-;; assume that Guru is giving rune offsets in the columns field.
-;; However, it is giving us byte offsets, causing us to highlight
-;; wrong ranges as soon as there's any multi-byte runes in the line.
+(defun go-guru--goto-byte (offset)
+ "Go to the OFFSETth byte in the buffer."
+ (goto-char (byte-to-position offset)))
+
+(defun go-guru--goto-byte-column (offset)
+ "Go to the OFFSETth byte in the current line."
+ (goto-char (byte-to-position (+ (position-bytes (point-at-bol)) (1-
offset)))))
+
(defun go-guru--goto-pos (posn)
"Find the file containing the position POSN (of the form `file:line:col')
set the point to it, switching the current buffer."
@@ -273,7 +277,7 @@ set the point to it, switching the current buffer."
(find-file (car file-line-pos))
(goto-char (point-min))
(forward-line (1- (string-to-number (cadr file-line-pos))))
- (forward-char (1- (string-to-number (caddr file-line-pos))))))
+ (go-guru--goto-byte-column (string-to-number (caddr file-line-pos)))))
(defun go-guru--goto-pos-no-file (posn)
"Given `file:line:col', go to the line and column. The file
@@ -281,7 +285,7 @@ component will be ignored."
(let ((file-line-pos (split-string posn ":")))
(goto-char (point-min))
(forward-line (1- (string-to-number (cadr file-line-pos))))
- (forward-char (1- (string-to-number (caddr file-line-pos))))))
+ (go-guru--goto-byte-column (string-to-number (caddr file-line-pos)))))
;;;###autoload
(defun go-guru-callees ()
@@ -477,8 +481,8 @@ end point."
(go-guru--enclosing-unique)))
(block (if (> (length enclosing) 0) (elt enclosing 0))))
(when block
- (goto-char (1+ (cdr (assoc 'start block))))
- (set-mark (1+ (cdr (assoc 'end block))))
+ (go-guru--goto-byte (1+ (cdr (assoc 'start block))))
+ (set-mark (byte-to-position (1+ (cdr (assoc 'end block)))))
(setq go-guru--last-enclosing (subseq enclosing 1))
(message "Region: %s" (cdr (assoc 'desc block)))
(setq deactivate-mark nil))))
- [nongnu] elpa/go-mode 1214f77 294/495: Bind go-goto-map to C-f, not C-g, (continued)
- [nongnu] elpa/go-mode 1214f77 294/495: Bind go-goto-map to C-f, not C-g, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode 17bd2b2 296/495: Add GOPATH detection, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode 9f785cc 298/495: Document stability of the master branch, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode f8b4bf9 300/495: Add to beginning of compilation-error-regexp-alist, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode cfaa193 348/495: cmd/guru: rename oracle to guru, copying it to a single package, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode 4d1ab9f 347/495: cmd/oracle: improve error messages, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode 9c2bf9b 360/495: cmd/guru: emacs: push mark in go-guru-definition, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode 5ef1d53 355/495: cmd/guru: use byte (not rune) count in -modified archive, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode 60ed26e 368/495: cmd/guru: emacs: only check modified buffers with file names, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode d209550 353/495: cmd/guru: emacs: minor changes to keybindings, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode 6ac5669 372/495: cmd/guru: emacs: interpret byte offsets correctly,
ELPA Syncer <=
- [nongnu] elpa/go-mode afb2a24 382/495: go.tools: use golang.org/x/... import paths, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode 3a82342 379/495: Regenerate AUTHORS, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode 8991b83 384/495: refactor/rename: emacs: kill go-rename buffer correctly, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode adea2e5 395/495: Make go-guru-build-tags a list of strings, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode d511e35 402/495: Replace obsolete one-argument form of ‘looking-back’., ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode 35f6826 404/495: Bump version to 1.5.0, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode da55ef1 413/495: Evaluate error conditions before prompting for new name, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode 59dfa96 423/495: Add confirmation prompt for Playground uploads, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode 13e9f22 428/495: Fix go-rename when buffer is not visiting any file, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode 9ab06b3 443/495: indent: fix nested dangling lines that don't use parens, ELPA Syncer, 2021/08/07