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

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

[nongnu] elpa/git-commit b6b6251: magit-refresh-get-relative-position: D


From: ELPA Syncer
Subject: [nongnu] elpa/git-commit b6b6251: magit-refresh-get-relative-position: Don't use count-lines
Date: Fri, 13 Aug 2021 16:57:19 -0400 (EDT)

branch: elpa/git-commit
commit b6b625134729ec52413cd126b4a76645f3279c28
Author: Jonas Bernoulli <jonas@bernoul.li>
Commit: Jonas Bernoulli <jonas@bernoul.li>

    magit-refresh-get-relative-position: Don't use count-lines
    
    This function does not reliably return the number of lines between
    two positions.  It returns either that, or that plus one; which is
    of course completely bonkers.
    
    Closes #4148.
---
 Documentation/RelNotes/3.3.0.org | 3 +++
 lisp/magit-mode.el               | 3 ++-
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/Documentation/RelNotes/3.3.0.org b/Documentation/RelNotes/3.3.0.org
index 9f7b760..2b30741 100644
--- a/Documentation/RelNotes/3.3.0.org
+++ b/Documentation/RelNotes/3.3.0.org
@@ -33,3 +33,6 @@
   a terminal.  If this change does not have any effect for you then
   your theme probably changes these faces and should stop doing so.
   #4206
+
+- In some cases refreshing a buffer caused the cursor to jump to a
+  different position.  #4148
diff --git a/lisp/magit-mode.el b/lisp/magit-mode.el
index 4d8e12b..8d50b04 100644
--- a/lisp/magit-mode.el
+++ b/lisp/magit-mode.el
@@ -1118,7 +1118,8 @@ Run hooks `magit-pre-refresh-hook' and 
`magit-post-refresh-hook'."
 (defun magit-refresh-get-relative-position ()
   (when-let ((section (magit-current-section)))
     (let ((start (oref section start)))
-      (list (count-lines start (point))
+      (list (- (line-number-at-pos (point))
+               (line-number-at-pos start))
             (- (point) (line-beginning-position))
             (and (magit-hunk-section-p section)
                  (region-active-p)



reply via email to

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