branch: externals/denote
commit be17fcb027eb685fd32d052157c094af2a8da1cc
Author: Protesilaos Stavrou <[email protected]>
Commit: Protesilaos Stavrou <[email protected]>

    Fix off-by-one jump to Org heading line
    
    This wouid match the wrong heading if there were no spaces between the
    headings. Thanks to kilesduli for bringing this matter to my attention
    in issue 354: <https://github.com/protesilaos/denote/issues/354>.
---
 denote-org-extras.el | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/denote-org-extras.el b/denote-org-extras.el
index 3205d7426b..23e94017be 100644
--- a/denote-org-extras.el
+++ b/denote-org-extras.el
@@ -72,9 +72,10 @@ the current file."
   "Return heading text and CUSTOM_ID from the given LINE in FILE."
   (with-current-buffer (find-file-noselect file)
     (save-excursion
-      (goto-char (point-min))
-      (forward-line line)
-      (cons (denote-link-ol-get-heading) (denote-link-ol-get-id)))))
+      (save-restriction
+        (goto-char (point-min))
+        (forward-line (1- line))
+        (cons (denote-link-ol-get-heading) (denote-link-ol-get-id))))))
 
 (defun denote-org-extras-format-link-with-heading (file heading-id description)
   "Prepare link to FILE with HEADING-ID using DESCRIPTION."

Reply via email to