@@ -213,33 +213,33 @@ This is a safety measure to prevent infinite loops."
213213 (seq-some (lambda (ov )
214214 (overlay-get ov 'invisible ))
215215 ovs))))
216- ; ; Skip over the invisible area in the appropriate direction
216+ ; ; Skip over the invisible area efficiently
217217 (let* ((pos (point ))
218- ; ; Find extent of invisibility
219- (invisible-beg pos)
220- (invisible-end pos)
221- ; ; Find overlays that might cause invisibility
222- (overlays (overlays-at pos)))
218+ (next-change nil )
219+ (prev-change nil ))
223220
224- ; ; Process text properties first (they're often faster)
225- (while (and (> invisible-beg (point-min ))
226- (invisible-p (1- invisible-beg)))
227- (setq invisible-beg (1- invisible-beg)))
221+ ; ; Find next visible position using text properties
222+ (setq next-change (next-single-property-change pos 'invisible nil (point-max )))
223+ (setq next-change (or next-change (point-max )))
228224
229- ( while ( and ( < invisible-end ( point-max ))
230- ( invisible-p ( 1+ invisible-end )))
231- (setq invisible-end ( 1+ invisible-end )))
225+ ; ; Find previous visible position using text properties
226+ ( setq prev-change ( previous-single-property-change pos 'invisible nil ( point-min )))
227+ (setq prev-change ( or prev-change ( point-min )))
232228
233- ; ; Then check overlays to see if they extend the invisible region
234- (dolist (ov overlays)
235- (when (overlay-get ov 'invisible )
236- (setq invisible-beg (min invisible-beg (overlay-start ov))
237- invisible-end (max invisible-end (overlay-end ov)))))
229+ ; ; Check overlays for invisibility boundaries
230+ (let ((next-ov-change (next-overlay-change pos))
231+ (prev-ov-change (previous-overlay-change pos)))
232+
233+ ; ; Update boundaries if overlay changes are closer
234+ (when (< next-ov-change next-change)
235+ (setq next-change next-ov-change))
236+ (when (> prev-ov-change prev-change)
237+ (setq prev-change prev-ov-change)))
238238
239- ; ; Now jump past the invisible region based on direction
239+ ; ; Jump in the appropriate direction
240240 (goto-char (if (eq direction 'backward )
241- ( max ( point-min ) ( 1- invisible-beg))
242- ( min ( point-max ) ( 1+ invisible-end)) ))
241+ prev-change
242+ next-change ))
243243
244244 ; ; Rerun the motion for consistency
245245 (call-interactively func)))
@@ -630,4 +630,4 @@ This is a safety measure to prevent infinite loops."
630630(define-key evilem-map " +" #'evilem-motion-next-line-first-non-blank )
631631
632632(provide 'evil-easymotion )
633- ; ;; evil-easymotion.el ends here
633+ ; ;; evil-easymotion.el ends here
0 commit comments