Skip to content

Commit

Permalink
Move point at least 1 char in markdown-match-propertized-text
Browse files Browse the repository at this point in the history
   `font-lock-fontify-keywords-region` expects the matcher to move the
   cursor forward and infloops otherwise.

   In markdown mode, on some occasions cached matched data at POS has
   end at (1- POS), which is strange but seems to be happening. Make
   sure that such anomalies don't infloop font-lock.
  • Loading branch information
vspinu committed Feb 27, 2016
1 parent 5969f49 commit 2250e4b
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions markdown-mode.el
Original file line number Diff line number Diff line change
Expand Up @@ -2891,13 +2891,17 @@ Return nil otherwise."
(defun markdown-match-propertized-text (property last)
"Match text with PROPERTY from point to LAST.
Restore match data previously stored in PROPERTY."
(let (saved pos)
(unless (setq saved (get-text-property (point) property))
(let ((saved (get-text-property (point) property))
pos)
(unless saved
(setq pos (next-single-char-property-change (point) property nil last))
(setq saved (get-text-property pos property)))
(when saved
(set-match-data saved)
(goto-char (min (1+ (match-end 0)) (point-max)))
;; Step at least one character beyond point. Otherwise
;; `font-lock-fontify-keywords-region' infloops.
(goto-char (min (1+ (max (match-end 0) (point)))
(point-max)))
saved)))

(defun markdown-match-pre-blocks (last)
Expand Down

0 comments on commit 2250e4b

Please sign in to comment.