Bladeren bron

ol: Fix `org-next-link' in an item tag

* lisp/ol.el (org-next-link): Fix `org-next-link' in an item tag.
* testing/lisp/test-ol.el (test-ol/next-link): Add test.
Nicolas Goaziou 6 jaren geleden
bovenliggende
commit
3375f039dd
2 gewijzigde bestanden met toevoegingen van 16 en 7 verwijderingen
  1. 9 6
      lisp/ol.el
  2. 7 1
      testing/lisp/test-ol.el

+ 9 - 6
lisp/ol.el

@@ -1307,12 +1307,15 @@ is non-nil, move backward."
     (setq org-link--search-failed nil)
     (catch :found
       (while (funcall search-fun org-link-any-re nil t)
-	(pcase (org-element-lineage (org-element-context) '(link) t)
-	  (`nil nil)
-	  (link
-	   (goto-char (org-element-property :begin link))
-	   (when (org-invisible-p) (org-show-context))
-	   (throw :found t))))
+	(let ((context (save-excursion
+			 (forward-char -1)
+			 (org-element-context))))
+	  (pcase (org-element-lineage context '(link) t)
+	    (`nil nil)
+	    (link
+	     (goto-char (org-element-property :begin link))
+	     (when (org-invisible-p) (org-show-context))
+	     (throw :found t)))))
       (goto-char pos)
       (setq org-link--search-failed t)
       (message "No further link found"))))

+ 7 - 1
testing/lisp/test-ol.el

@@ -320,7 +320,13 @@
 	    (let* ((this-command 'org-next-link)
 		   (last-command this-command))
 	      (org-next-link))
-	    (buffer-substring (point) (line-end-position))))))
+	    (buffer-substring (point) (line-end-position)))))
+  ;; Find links with item tags.
+  (should
+   (equal "[[link1]]"
+	  (org-test-with-temp-text "- tag [[link1]] :: description"
+	    (org-next-link)
+	    (buffer-substring (point) (search-forward "]]" nil t))))))
 
 (ert-deftest test-ol/previous-link ()
   "Test `org-previous-link' specifications."