* lisp/ol.el (org-next-link): Do not skip links when searching backwards. Reported-by: stardiviner <numbchild@gmail.com> <http://lists.gnu.org/r/emacs-orgmode/2019-04/msg00022.html>
@@ -1308,7 +1308,7 @@ is non-nil, move backward."
(catch :found
(while (funcall search-fun org-link-any-re nil t)
(let ((context (save-excursion
- (forward-char -1)
+ (unless search-backward (forward-char -1))
(org-element-context))))
(pcase (org-element-lineage context '(link) t)
(`nil nil)
@@ -352,6 +352,11 @@
(org-test-with-temp-text "[[link1]]\n[[link2<point>]]"
(org-previous-link)
(buffer-substring (point) (line-end-position)))))
+ (should
+ (equal "[[link1]]"
+ (org-test-with-temp-text "line\n[[link1]]\n[[link2<point>]]"
+ (org-previous-link)
+ (buffer-substring (point) (line-end-position)))))
;; Ignore fake links.
(should
(equal "[[truelink]]"