|
120 | 120 | (t |
121 | 121 | (shr-generic td))))))))) |
122 | 122 |
|
| 123 | +(defun pr-review--restore-diff-syntax-overlays () |
| 124 | + "Restore diff syntax highlighting overlays with high priority. |
| 125 | +This ensures diff syntax highlighting overlays override section highlight overlays." |
| 126 | + (remove-overlays (point-min) (point-max) 'pr-review-diff-syntax t) |
| 127 | + (let ((pos (point-min))) |
| 128 | + (while (< pos (point-max)) |
| 129 | + (when-let ((face (get-text-property pos 'pr-review-diff-syntax-face))) |
| 130 | + (let* ((end (or (next-single-property-change pos 'pr-review-diff-syntax-face nil (point-max)) |
| 131 | + (point-max))) |
| 132 | + (ov (make-overlay pos end))) |
| 133 | + (overlay-put ov 'pr-review-diff-syntax t) |
| 134 | + (overlay-put ov 'font-lock-face face) |
| 135 | + (overlay-put ov 'priority 1) ; Higher than magit-section-highlight (priority 0) |
| 136 | + (overlay-put ov 'evaporate t) |
| 137 | + (setq pos end))) |
| 138 | + (setq pos (or (next-single-property-change pos 'pr-review-diff-syntax-face nil (point-max)) |
| 139 | + (point-max)))))) |
| 140 | + |
123 | 141 | (defun pr-review--insert-html (body &optional indent extra-face) |
124 | 142 | "Insert html content BODY. |
125 | 143 | INDENT is an optional number, if provided, |
@@ -213,9 +231,14 @@ MARGIN count of spaces are added at the start of every line." |
213 | 231 | (dolist (ol (overlays-in (point-min) (point-max))) |
214 | 232 | (when (eq (overlay-get ol 'diff-mode) 'syntax) |
215 | 233 | (when-let ((face (overlay-get ol 'face))) |
216 | | - (add-face-text-property (overlay-start ol) |
217 | | - (overlay-end ol) |
218 | | - face)))) |
| 234 | + ;; Store syntax face info for later high-priority overlay recreation |
| 235 | + (put-text-property (overlay-start ol) |
| 236 | + (overlay-end ol) |
| 237 | + 'pr-review-diff-syntax-face face) |
| 238 | + ;; Also set font-lock-face for Magit v4.4.0+ compatibility |
| 239 | + (put-text-property (overlay-start ol) |
| 240 | + (overlay-end ol) |
| 241 | + 'font-lock-face face)))) |
219 | 242 | (goto-char (point-min)) |
220 | 243 | (remove-overlays (point-min) (point-max) 'diff-mode 'syntax))) |
221 | 244 |
|
@@ -961,6 +984,10 @@ it can be displayed in a single line." |
961 | 984 | (propertize (alist-get 'title pr)'font-lock-face 'pr-review-title-face))) |
962 | 985 | (insert "\n") |
963 | 986 | (pr-review--insert-pr-body pr diff)) |
| 987 | + ;; Create high-priority overlays for diff syntax highlighting |
| 988 | + (pr-review--restore-diff-syntax-overlays) |
| 989 | + ;; Add hook to restore overlays after section highlighting |
| 990 | + (add-hook 'post-command-hook #'pr-review--restore-diff-syntax-overlays nil t) |
964 | 991 | ;; need to call after this inserting all sections |
965 | 992 | (pr-review--hide-generated-files)) |
966 | 993 |
|
|
0 commit comments