- ;; otherwise validate-prepare will say there's nothing to do.
- ;; Don't use (point-max) because we may be narrowed.
- (if (> rng-validate-up-to-date-end (buffer-size))
- (setq rng-validate-up-to-date-end
- (max 1 (1- rng-validate-up-to-date-end))))
+ ;; otherwise rng-validate-prepare will say there's nothing to do.
+ (when (>= rng-validate-up-to-date-end (point-max))
+ (setq rng-validate-up-to-date-end
+ (if (< (point-min) (point-max))
+ (1- (point-max))
+ ;; Only widen if really necessary.
+ (save-restriction (widen) (max (point-min) (1- (point-max)))))))