Skip to content

Commit

Permalink
Correct beginning of inline code position
Browse files Browse the repository at this point in the history
markdown-regex-code starts with "\(?:\`\|[^\]\)\(\(`+\)...". If cursor is
beginning of buffer, "(match-beginning 0)" is on backtick. While cursor is not
beginning of buffer, "(match-beginning 0)" is not on backtick and previous point
of backtick.

---
foo:bar
---
`x`

In above example, "(match-beginning 0)" is point of after "---". That point is
a code block and "(markdown-code-block-at-pos pos)" returns non-nil,
this causes infinite loop of markdown-match-inline-generic.
"(match-beginning 1)" of markdown-regex-code always on backtick. We should
use "(match-beginning 1)" instead of "(match-beginning 0)" in such case.
  • Loading branch information
syohex committed Mar 11, 2016
1 parent dd7fd4c commit aea5120
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion markdown-mode.el
Original file line number Diff line number Diff line change
Expand Up @@ -2805,7 +2805,7 @@ Return nil otherwise."
(defun markdown-match-inline-generic (regex last)
"Match inline REGEX from the point to LAST."
(when (re-search-forward regex last t)
(let ((bounds (markdown-code-block-at-pos (match-beginning 0))))
(let ((bounds (markdown-code-block-at-pos (match-beginning 1))))
(if (null bounds)
;; Not in a code block: keep match data and return t when in bounds
(<= (match-end 0) last)
Expand Down

0 comments on commit aea5120

Please sign in to comment.