branch: elpa/aidermacs
commit 01f04e0437e45d0ea5c927542e42da0028e4904b
Author: Mingde (Matthew) Zeng <[email protected]>
Commit: Mingde (Matthew) Zeng <[email protected]>
Warns user when font-lock position breaks
Addresses #87
Signed-off-by: Mingde (Matthew) Zeng <[email protected]>
---
aidermacs-backend-comint.el | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/aidermacs-backend-comint.el b/aidermacs-backend-comint.el
index ec7cd6bea1..8d0c4e7379 100644
--- a/aidermacs-backend-comint.el
+++ b/aidermacs-backend-comint.el
@@ -241,19 +241,21 @@ _OUTPUT is the text to be processed."
;; Apply the faces to the buffer
(remove-overlays aidermacs--syntax-block-start-pos
aidermacs--syntax-block-end-pos)
-
+
(catch 'break
- (while (< pos aidermacs--syntax-block-end-pos)
+ (while (< pos aidermacs--syntax-block-end-pos)
(let* ((next-font-pos (or (next-property-change font-pos fontified)
(length fontified)))
(next-pos (+ aidermacs--syntax-block-start-pos next-font-pos))
(face (get-text-property font-pos 'face fontified)))
(ansi-color-apply-overlay-face pos next-pos face)
+ ;; Detect potential infinite loop - position didn't advance
(when (eq pos next-pos)
+ (warn "Font-lock position didn't advance at pos %d, breaking out
of loop to prevent hang" pos)
(throw 'break nil))
-
+
(setq pos next-pos
font-pos next-font-pos)))))
-
+
;; If we found the end marker, finalize the block
(when end-of-block-p
(when (equal aidermacs--syntax-block-delimiter aidermacs-diff-marker)