branch: elpa/eglot-inactive-regions commit 3f04bf2ba87fe54b01860a89d50cae612e3cc3b8 Author: Filippo Argiolas <filippo.argio...@gmail.com> Commit: Filippo Argiolas <filippo.argio...@gmail.com>
limit next-single-property-change result Clamp next-single-property-change result to the region we are fontifying. Should fix #3. Also remove some widening while creating the overlays with darken-foreground fontification hook. Not sure why it was introduced but I don't think we need it. --- eglot-inactive-regions.el | 31 ++++++++++++++----------------- 1 file changed, 14 insertions(+), 17 deletions(-) diff --git a/eglot-inactive-regions.el b/eglot-inactive-regions.el index d37782bc04..bd459d3317 100644 --- a/eglot-inactive-regions.el +++ b/eglot-inactive-regions.el @@ -206,14 +206,14 @@ If the correspondend \"eglot-inactive\" face doesn't not exist yet create it." (defun eglot-inactive-regions--fontify (start end &optional verbose) "Fontify inactive region (START END) with semitransparent faces." - ;; sometimes font lock fontifies in chunks and each fontification - ;; functions takes care of extending the region to something - ;; syntactically relevant... guess we need to do the same, extend to - ;; cover whole lines seems to work with c modes (ignore verbose) (when (and eglot-inactive-regions-mode eglot-inactive-regions--active (eq eglot-inactive-regions-style 'darken-foreground)) + ;; sometimes font lock fontifies in chunks and each fontification + ;; functions takes care of extending the region to something + ;; syntactically relevant... guess we need to do the same, extend to + ;; cover whole lines seems to work with c modes (save-excursion (save-restriction (widen) @@ -228,8 +228,7 @@ If the correspondend \"eglot-inactive\" face doesn't not exist yet create it." ;; find the inactive region inside the region to fontify (while (and start (< start end)) (let* ((from (or (text-property-any start end 'eglot-inactive-region t) end)) - (to (or (text-property-any from end 'eglot-inactive-region nil) end)) - (beg from)) + (to (or (text-property-any from end 'eglot-inactive-region nil) end))) ;; the idea here is to iterate through the region by syntax ;; blocks, derive a new face from current one with dimmed ;; foreground and apply the new face with an overlay @@ -240,17 +239,15 @@ If the correspondend \"eglot-inactive\" face doesn't not exist yet create it." ;; an eye on it while I find a solution (when (> to from) (save-excursion - (save-restriction - (widen) - (goto-char from) - (while (< (point) to) - (goto-char (or (next-single-property-change (point) 'face) to)) - (let* ((cur-face (eglot-inactive-regions--get-face (1- (point)))) - (eglot-inactive-face (eglot-inactive-regions--make-darken-face cur-face)) - (ov (make-overlay beg (point)))) - (overlay-put ov 'face eglot-inactive-face) - (push ov eglot-inactive-regions--overlays)) - (setq beg (point)))))) + (goto-char from) + (while (< (point) to) + (goto-char (min to (or (next-single-property-change (point) 'face) to))) + (let* ((cur-face (eglot-inactive-regions--get-face (1- (point)))) + (eglot-inactive-face (eglot-inactive-regions--make-darken-face cur-face)) + (ov (make-overlay from (point)))) + (overlay-put ov 'face eglot-inactive-face) + (push ov eglot-inactive-regions--overlays)) + (setq from (point))))) (setq start to))))) (defun eglot-inactive-regions-refresh ()