[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] scratch/add-vdiff 85a4d4e 087/258: Fix point jumping after sendin
From: |
Justin Burkett |
Subject: |
[elpa] scratch/add-vdiff 85a4d4e 087/258: Fix point jumping after sending changes |
Date: |
Wed, 17 May 2017 08:13:28 -0400 (EDT) |
branch: scratch/add-vdiff
commit 85a4d4ed1858d61bbb6166f9d31af6f66b43b942
Author: justbur <address@hidden>
Commit: justbur <address@hidden>
Fix point jumping after sending changes
Don't hide point from add-folds
---
vdiff.el | 117 ++++++++++++++++++++++++++++++++-------------------------------
1 file changed, 59 insertions(+), 58 deletions(-)
diff --git a/vdiff.el b/vdiff.el
index f5d7f64..98f4cea 100644
--- a/vdiff.el
+++ b/vdiff.el
@@ -417,7 +417,8 @@ parsing the diff output and triggering the overlay updates."
(let ((a-fold (vdiff--make-fold a-buffer a-range))
(b-fold (vdiff--make-fold b-buffer b-range)))
(dolist (fold (list a-fold b-fold))
- (cond ((or (vdiff--point-in-fold-p fold)
+ (cond ((or (vdiff--point-in-fold-p a-fold)
+ (vdiff--point-in-fold-p b-fold)
vdiff--all-folds-open)
(vdiff--set-open-fold-props fold))
(t
@@ -447,62 +448,61 @@ parsing the diff output and triggering the overlay
updates."
(defun vdiff--refresh-overlays ()
"Delete and recreate overlays in both buffers."
(vdiff--remove-all-overlays)
- (save-excursion
- (let ((a-buffer (car vdiff--buffers))
- (b-buffer (cadr vdiff--buffers))
- (a-line 1)
- (b-line 1)
- (a-last-post 1)
- (b-last-post 1)
- folds)
- (save-excursion
- (with-current-buffer a-buffer
- (widen)
- (goto-char (point-min)))
- (with-current-buffer b-buffer
- (widen)
- (goto-char (point-min)))
- (dolist (header vdiff--diff-data)
- (let* ((code (nth 0 header))
- (a-range (nth 1 header))
- (b-range (nth 2 header))
- (a-beg (car a-range))
- (a-end (cdr a-range))
- (a-post (if (string= code "a") a-end (1+ a-end)))
- (a-len (1+ (- a-end a-beg)))
- (b-beg (car b-range))
- (b-end (cdr b-range))
- (b-post (if (string= code "d") b-end (1+ b-end)))
- (b-len (1+ (- b-end b-beg))))
-
- (unless (member code (list "a" "d" "c"))
- (user-error "vdiff: Unexpected code in diff output"))
-
- (push (cons (cons a-last-post (1- a-beg))
- (cons b-last-post (1- b-beg)))
- folds)
- (setq a-last-post a-post)
- (setq b-last-post b-post)
-
- (let (ovr-a ovr-b)
- (with-current-buffer a-buffer
- (forward-line (- a-beg a-line))
- (setq a-line a-beg)
- (setq ovr-a (vdiff--add-diff-overlay t code a-len b-len)))
- (with-current-buffer b-buffer
- (forward-line (- b-beg b-line))
- (setq b-line b-beg)
- (setq ovr-b (vdiff--add-diff-overlay nil code b-len a-len)))
- (overlay-put ovr-a 'vdiff-other-overlay ovr-b)
- (overlay-put ovr-b 'vdiff-other-overlay ovr-a))))
- (push (cons (cons a-last-post
- (with-current-buffer a-buffer
- (line-number-at-pos (point-max))))
- (cons b-last-post
- (with-current-buffer b-buffer
- (line-number-at-pos (point-max)))))
- folds)
- (vdiff--add-folds a-buffer b-buffer folds)))))
+ (let ((a-buffer (car vdiff--buffers))
+ (b-buffer (cadr vdiff--buffers))
+ (a-line 1)
+ (b-line 1)
+ (a-last-post 1)
+ (b-last-post 1)
+ folds)
+ (save-excursion
+ (with-current-buffer a-buffer
+ (widen)
+ (goto-char (point-min)))
+ (with-current-buffer b-buffer
+ (widen)
+ (goto-char (point-min)))
+ (dolist (header vdiff--diff-data)
+ (let* ((code (nth 0 header))
+ (a-range (nth 1 header))
+ (b-range (nth 2 header))
+ (a-beg (car a-range))
+ (a-end (cdr a-range))
+ (a-post (if (string= code "a") a-end (1+ a-end)))
+ (a-len (1+ (- a-end a-beg)))
+ (b-beg (car b-range))
+ (b-end (cdr b-range))
+ (b-post (if (string= code "d") b-end (1+ b-end)))
+ (b-len (1+ (- b-end b-beg))))
+
+ (unless (member code (list "a" "d" "c"))
+ (user-error "vdiff: Unexpected code in diff output"))
+
+ (push (cons (cons a-last-post (1- a-beg))
+ (cons b-last-post (1- b-beg)))
+ folds)
+ (setq a-last-post a-post)
+ (setq b-last-post b-post)
+
+ (let (ovr-a ovr-b)
+ (with-current-buffer a-buffer
+ (forward-line (- a-beg a-line))
+ (setq a-line a-beg)
+ (setq ovr-a (vdiff--add-diff-overlay t code a-len b-len)))
+ (with-current-buffer b-buffer
+ (forward-line (- b-beg b-line))
+ (setq b-line b-beg)
+ (setq ovr-b (vdiff--add-diff-overlay nil code b-len a-len)))
+ (overlay-put ovr-a 'vdiff-other-overlay ovr-b)
+ (overlay-put ovr-b 'vdiff-other-overlay ovr-a))))
+ (push (cons (cons a-last-post
+ (with-current-buffer a-buffer
+ (line-number-at-pos (point-max))))
+ (cons b-last-post
+ (with-current-buffer b-buffer
+ (line-number-at-pos (point-max)))))
+ folds))
+ (vdiff--add-folds a-buffer b-buffer folds)))
;; * Moving changes
@@ -569,7 +569,8 @@ changes under point or on the immediately preceding line."
(unless addition
(delete-region (overlay-start other-ovr)
(overlay-end other-ovr)))
- (insert text)
+ (save-excursion
+ (insert text))
(delete-overlay other-ovr))
(delete-overlay ovr))))
- [elpa] scratch/add-vdiff 3fcf4b9 101/258: Fix sign problem in adding hunk overlays, (continued)
- [elpa] scratch/add-vdiff 3fcf4b9 101/258: Fix sign problem in adding hunk overlays, Justin Burkett, 2017/05/17
- [elpa] scratch/add-vdiff 9346e46 106/258: Simplify method for setting vscroll, Justin Burkett, 2017/05/17
- [elpa] scratch/add-vdiff c46b76b 111/258: Set window point on scroll, Justin Burkett, 2017/05/17
- [elpa] scratch/add-vdiff fd8c973 109/258: Remove post-command-hook, Justin Burkett, 2017/05/17
- [elpa] scratch/add-vdiff 25a7516 128/258: Only run scroll-function once per command, Justin Burkett, 2017/05/17
- [elpa] scratch/add-vdiff 25ec344 134/258: Require diff-mode so that diff-mode faces are available, Justin Burkett, 2017/05/17
- [elpa] scratch/add-vdiff 371febc 135/258: Add option to automatically refine hunks, Justin Burkett, 2017/05/17
- [elpa] scratch/add-vdiff 9b3ffb0 150/258: Don't distiguish exit code 0 from 1, Justin Burkett, 2017/05/17
- [elpa] scratch/add-vdiff d33845c 167/258: Minor change in cleanup, Justin Burkett, 2017/05/17
- [elpa] scratch/add-vdiff edfae89 176/258: Cleanup vdiff-buffers, Justin Burkett, 2017/05/17
- [elpa] scratch/add-vdiff 85a4d4e 087/258: Fix point jumping after sending changes,
Justin Burkett <=
- [elpa] scratch/add-vdiff f041c58 102/258: Sync lines after sending changes, Justin Burkett, 2017/05/17
- [elpa] scratch/add-vdiff 88ce867 088/258: Initial attempt at refine commands, Justin Burkett, 2017/05/17
- [elpa] scratch/add-vdiff f3ca6cb 110/258: Tweak vscroll function, Justin Burkett, 2017/05/17
- [elpa] scratch/add-vdiff 84380fb 113/258: Delete unused lexical vars, Justin Burkett, 2017/05/17
- [elpa] scratch/add-vdiff 40351c6 079/258: Exit hydra on vdiff exit, Justin Burkett, 2017/05/17
- [elpa] scratch/add-vdiff 4bb84e4 073/258: Add update command to hydra, Justin Burkett, 2017/05/17
- [elpa] scratch/add-vdiff 81478be 117/258: Lock diff data for certain operations, Justin Burkett, 2017/05/17
- [elpa] scratch/add-vdiff 20bd4b4 092/258: Change terminology, Justin Burkett, 2017/05/17
- [elpa] scratch/add-vdiff 3d8e224 127/258: Simplify insertion arrow code, Justin Burkett, 2017/05/17
- [elpa] scratch/add-vdiff bd80900 126/258: Merge pull request #7 from syohex/fix-package, Justin Burkett, 2017/05/17