Skip to content

Commit fc729ea

Browse files
committed
WIP: fix+add tests for markdown-do link jump
1 parent d917e71 commit fc729ea

File tree

2 files changed

+30
-3
lines changed

2 files changed

+30
-3
lines changed

markdown-mode.el

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8222,9 +8222,6 @@ Jumps between reference links and definitions; between footnote
82228222
markers and footnote text."
82238223
(interactive)
82248224
(cond
8225-
;; Link
8226-
((or (markdown-link-p) (markdown-wiki-link-p))
8227-
(markdown-follow-thing-at-point nil))
82288225
;; Footnote definition
82298226
((markdown-footnote-text-positions)
82308227
(markdown-footnote-return))
@@ -8237,6 +8234,9 @@ markers and footnote text."
82378234
;; Reference definition
82388235
((thing-at-point-looking-at markdown-regex-reference-definition)
82398236
(markdown-reference-goto-link (match-string-no-properties 2)))
8237+
;; Link
8238+
((or (markdown-link-p) (markdown-wiki-link-p))
8239+
(markdown-follow-thing-at-point nil))
82408240
;; GFM task list item
82418241
((markdown-gfm-task-list-item-at-point)
82428242
(markdown-toggle-gfm-checkbox))

tests/markdown-test.el

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1558,6 +1558,33 @@ the opening bracket of [^2], and then subsequent functions would kill [^2])."
15581558
(markdown-footnote-kill)
15591559
(should (string-equal (current-kill 0) "foo\n")))))
15601560

1561+
(ert-deftest test-markdown-do/jump-wikilink ()
1562+
"Test `markdown-do' jumps to wiki links"
1563+
(markdown-test-string
1564+
"[[Foo]]"
1565+
(goto-char 3) ; Foo
1566+
(markdown-do) ; open Foo.md
1567+
(should (string= (buffer-string) ""))))
1568+
1569+
(ert-deftest test-markdown-do/jump-link ()
1570+
"Test `markdown-do' jumps to markdown links"
1571+
(markdown-test-string
1572+
"[bar](https://duckduckgo.com)"
1573+
(goto-char 3) ; Foo
1574+
(markdown-do) ; open browser
1575+
(should (string= (buffer-string) ""))))
1576+
1577+
(ert-deftest test-markdown-do/wikilink-in-table ()
1578+
"Test `markdown-do' jumps to markdown links"
1579+
(markdown-test-string
1580+
"| [[Foo]] |"
1581+
(goto-char 1) ; Table cell
1582+
(markdown-do) ; align
1583+
(should (string= (buffer-string) "| [[Foo]] |"))
1584+
(goto-char 4) ; Foo
1585+
(markdown-do) ; open Foo.md
1586+
(should (string= (buffer-string) "| [[Foo]] |"))))
1587+
15611588
(ert-deftest test-markdown-footnote-reference/jump ()
15621589
"Test `markdown-do' for footnotes and reference links."
15631590
(markdown-test-string

0 commit comments

Comments
 (0)