Browse Source

Fix overlay copy

master
10sr 6 years ago
parent
commit
3663fa52f6
Signed by: 10sr GPG Key ID: 7BEC428194130EB2
1 changed files with 18 additions and 8 deletions
  1. +18
    -8
      emacs.el

+ 18
- 8
emacs.el View File

@@ -2333,10 +2333,20 @@ TYPE is target object type."
(current-buffer)))))) (current-buffer))))))


(defun git-walktree--replace-into-buffer (target) (defun git-walktree--replace-into-buffer (target)
"Replace TARGET buffer contents with that of current buffer."
(let ((buf (current-buffer)))
"Replace TARGET buffer contents with that of current buffer.
It also copy text overlays."
(let ((src (current-buffer)))
(with-current-buffer target (with-current-buffer target
(replace-buffer-contents buf))))
(replace-buffer-contents src)))

(let ((overlays (overlays-in (point-min) (point-max))))
(dolist (o overlays)
(let ((beg (overlay-start o))
(end (overlay-end o)))
(move-overlay (copy-overlay o)
beg
end
target)))))


(require 'ansi-color) (require 'ansi-color)
(defun git-walktree--open-treeish (commitish path treeish) (defun git-walktree--open-treeish (commitish path treeish)
@@ -2359,6 +2369,8 @@ TYPE is target object type."
(cd git-walktree-repository-root) (cd git-walktree-repository-root)
(save-excursion (save-excursion
(let ((inhibit-read-only t)) (let ((inhibit-read-only t))
;; Remove existing overlays generated by ansi-color-apply-on-region
(remove-overlays)
(with-temp-buffer (with-temp-buffer
(if commitish (if commitish
(progn (git-walktree--call-process nil (progn (git-walktree--call-process nil
@@ -2370,6 +2382,8 @@ TYPE is target object type."
"--decorate" "--decorate"
"--stat" "--stat"
commitish) commitish)
(ansi-color-apply-on-region (point-min)
(point))
(insert "\n") (insert "\n")
(insert (format "Contents of '%s:%s':\n" (insert (format "Contents of '%s:%s':\n"
(git-walktree--commitish-fordisplay commitish) (git-walktree--commitish-fordisplay commitish)
@@ -2384,11 +2398,7 @@ TYPE is target object type."


treeish) treeish)
(git-walktree--replace-into-buffer buf)) (git-walktree--replace-into-buffer buf))
;; Overlays won't be copied with replace-buffer-contents so do this
;; after copying contents
(remove-overlays)
(ansi-color-apply-on-region (point-min)
(point-max))))
))
(git-walktree-mode) (git-walktree-mode)
(set-buffer-modified-p nil) (set-buffer-modified-p nil)




Loading…
Cancel
Save