Fanael / edit-indirect

Edit regions in separate buffers
99 stars 23 forks source link

Don't truncate overlays #5

Closed AdamNiederer closed 6 years ago

AdamNiederer commented 6 years ago

When calling edit-indirect-region on a region with overlays, edit-indirect will truncate the the overlays to their starting position. It will, however, respect overlays which are a superset of the region sent to the indirect buffer.

Simple repro (run each statement sequentially with C-x C-e)

(setq my-ol (make-overlay 10 50))
(assert (= 1 (length (overlays-at 25))))
(edit-indirect-region 10 50 (current-buffer))
;; Run edit-indirect-commit in the indirect buffer
(assert (= 1 (length (overlays-at 25)))) ;; Will fail; my-ol is now from 10 to 10
(mapcar #'delete-overlay (overlays-at 25)) ;; Cleanup

(setq my-ol (make-overlay 10 50))
(assert (= 1 (length (overlays-at 25))))
(edit-indirect-region 20 30 (current-buffer))
;; Run edit-indirect-commit in the indirect buffer
(assert (= 1 (length (overlays-at 25)))) ;; Will pass
(mapcar #'delete-overlay (overlays-at 25)) ;; Cleanup